forked from rails/solid_queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Merge latest upstream solid_queue v1.5.0 (adopts PR #11 + adds a semaphore guard) #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8cdf9b7
Accept optional job argument in stopping?
thoughtless 5eb7345
Use dynamic port allocation in Puma plugin tests
diogovernier 60cc071
docs: use single splat in `key` argument for `limits_concurrency`
G-Rath c59652e
Warn instead of raising when the connection pool is smaller than the β¦
ajaynomics e0b8d3e
add bin/jobs check to validate config before starting
alexanderadam fb4fd80
Refactor errors and warnings when parsing configuration
rosa ba4b7b3
Remove trapping QUIT on Windows
andyundso b7998e3
Change default polling_interval to 1 sec
hachi8833 0b9c51a
Memoize Runnable#mode to stop allocating a String + StringInquirer peβ¦
0bd75b7
Avoid reloading job rows after dispatch and schedule
ImDineshSaini 65784de
Fix recurring task double-enqueue caused by wall-clock race condition
ghiculescu fa86663
Improve DISTINCT queries on PostgreSQL via recursive CTE
bubiche 7bd69e4
Automatically use Rails or a default timezone for the schedule
andyjeffries 64aa4fc
Fix flaky concurrency controls test
diogovernier 94c50ec
Bypass JobResult's query cache in skip_active_record_query_cache
rafael-pissardo 42a6441
Reduce flaky integration test failures from timing and PK reuse
rafael-pissardo 005f96d
Support running with strict_loading_by_default enabled
JoeDupuis 8c6fb2f
Report rescued recurring enqueue errors to Rails.error
rafael-pissardo b439699
Drop support for Ruby 3.1
rosa 1efcee9
Guard signal_all against incrementing semaphore beyond its limit
mhenrixon db46f08
Prevent wrong release of blocked jobs and semaphore corruption
tblais1224 d0783cc
Bump solid_queue to 1.5.0
rosa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module SolidQueue | ||
| class Record | ||
| module DistinctValues | ||
| extend ActiveSupport::Concern | ||
|
|
||
| # PostgreSQL has no native loose index scan, so a plain DISTINCT on a leading | ||
| # index column degrades to a full index scan on large tables. We emulate one | ||
| # with a recursive CTE that walks the index jumping between distinct values. | ||
| class_methods do | ||
| def distinct_values_of(column) | ||
| if loose_index_scan_emulation_needed? | ||
| loose_distinct_via_recursive_cte(column) | ||
| else | ||
| distinct.pluck(column) | ||
| end | ||
| end | ||
|
|
||
| private | ||
| def loose_index_scan_emulation_needed? | ||
| connection.adapter_name == "PostgreSQL" | ||
| end | ||
|
|
||
| # Emulates a loose index scan, honoring the current scope (e.g. LIKE prefixes) | ||
| # by building the anchor and the recursive step as scoped relations, whose | ||
| # #to_sql inlines any bind parameters so they can be embedded in the raw CTE. | ||
| def loose_distinct_via_recursive_cte(column) | ||
| col = connection.quote_column_name(column) | ||
|
|
||
| connection.select_values(<<~SQL.squish) | ||
| WITH RECURSIVE t AS ( | ||
| (#{next_distinct_value(col, "#{col} IS NOT NULL")}) | ||
| UNION ALL | ||
| SELECT (#{next_distinct_value(col, "#{col} > t.#{col}")}) FROM t WHERE t.#{col} IS NOT NULL | ||
| ) | ||
| SELECT #{col} FROM t WHERE #{col} IS NOT NULL | ||
| SQL | ||
| end | ||
|
|
||
| # Smallest value of `col` within the current scope that matches `condition`. | ||
| def next_distinct_value(col, condition) | ||
| all.where(Arel.sql(condition)).reorder(Arel.sql(col)).limit(1).select(Arel.sql(col)).to_sql | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π«