Repository navigation
Escape LIKE metacharacters in queue prefixes - #811
Merged
Merged
Conversation
Contributor
Author
|
The CI matrix on the current head was cancelled mid-run - the jobs show cancelled, not failed. The focused tests pass locally. Could a maintainer re-run the workflow when convenient? Happy to push a rebase if that helps. |
A worker prefix such as mail_* became LIKE 'mail_%', so _ and % matched any character. When that false match was the only row, the selector returned it without the literal prefix check and the worker claimed a queue it was not configured to run.
ESCAPE '\' is a valid string on SQLite and PostgreSQL, but MySQL treats the backslash as an escape and rejects the clause. MySQL needs the same one-character escape written as '\\'.
A backslash needs doubling inside MySQL string literals but not in SQLite or PostgreSQL, which is why the LIKE clause checked the adapter. Escaping with ! works the same everywhere, so the check goes away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A worker listing queue_* and queue_b*, or queue_b* and queue_b1, polled queue_b1 twice on every pass and counted its jobs twice. Prefix matches were never removed from the remaining names, because `queues -= matches` only reassigned the block's local variable, and a queue matched both by name and by a prefix came back from both lookups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rosa
force-pushed
the
escape-queue-prefix-like-wildcards
branch
from
November 3, 2026 07:41
101dbf7 to
cf15cc6
Compare
Member
|
Thanks a lot, @afurm! I rebased this onto main, dropped the two empty commits to retrigger CI (main has the json fix now, so the Ruby 3.2 jobs should pass), and added two commits on top:
|
This was referenced Nov 3, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
QueueSelectorturns a worker prefix such asmail_*into a SQLLIKEpattern._and%in that prefix were left unescaped, soLIKE 'mail_%'also matchedmailboxormail-ops.*is still the only wildcard.When that false match was the only row,
in_raw_orderreturned it immediately becausequeues.one?skipped the literalstart_with?filter. The worker then claimed jobs from a queue it was not configured to run.Why
_and%are escaped (viasanitize_sql_like) before*is replaced with%, and theLIKEclause setsESCAPE '\'so the escape works on SQLite as well as MySQL and PostgreSQL. Prefix matches always go through the literal filter, including when only one name comes back, so a falseLIKEhit is not claimed.A regression test covers a prefix that is the only
LIKEhit but not a literal match, and a realmail_*/100%_*queue that should still be claimed.