Repository navigation
Fuzzy job class search and queue filter - #19
Open
ryanmrodriguez wants to merge 1 commit into
Open
ryanmrodriguez wants to merge 1 commit into
ryanmrodriguez wants to merge 1 commit into
Conversation
Class search was a case-sensitive prefix match and the queue filter an exact match, so "Docu" never found UserDocumentScreenshotJob. Both are now a case-insensitive substring match. Fragments are resolved in Ruby against the distinct names Solid Queue holds (Flightdeck::KnownNames), leaving SQL an indexed IN list instead of a leading-wildcard LIKE that would scan the jobs table for every list, tab count and bulk action. Case folding is then the same on every adapter. The names are memoized per process for one poll interval, re-read before answering "no matches", and read fresh inside retry/discard so "all matching" never skips a job with a brand-new class or queue.
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.
Problem
On the Jobs page, class search was a case-sensitive prefix match and the queue filter needed the exact queue name. Typing
Docufound nothing, even with dozens of failedCoreModels::Screenshots::UserDocumentScreenshotJobs on screen.Change
Both fields are now a case-insensitive substring match:
chargefindsBilling::ChargeSubscriptionJob,HOOKfindswebhooks.The obvious fix,
LIKE '%frag%', can't use an index, so every list, all seven tab counts and bulk "all matching" would scan the jobs table. Instead,Flightdeck::KnownNamesmatches the fragment in Ruby against the distinct class and queue names (SELECT DISTINCTover the existingclass_name/queue_nameindexes), andJobsQueryfilters with an indexedIN (...). A side benefit is that case folding is the same on every adapter (SQLite'sLIKEfolds ASCII only, MySQL's depends on collation).Freshness and cost
Rails.cache, so a filtered page costs a couple ofDISTINCTs per interval even with no cache store.KnownNames.fresh { }, so "all matching" never skips a job with a brand-new class or queue name.The exact
class_nameparam filter is unchanged.Known limitation: on accent-insensitive MySQL collations,
INcan match collation-equivalent names (e.g.emailvsémail). The old exact queue filter behaved the same way.Testing
test/known_names_test.rb: query count with no cache store, TTL expiry, no-match re-read and its rate limit, slow reads, contended threads sharing one read, query cache bypass, nested/raisingfresh.bundle exec rake testandFLIGHTDECK_TEST_API_ONLY=1 bundle exec rake test: 298 runs, 0 failures each (SQLite locally; PostgreSQL/MySQL via CI). Rubocop clean.bin/demo.