Destroy orphan BlockedExecution rows when the job class no longer resolves - #783
Open
julik wants to merge 1 commit into
Open
Destroy orphan BlockedExecution rows when the job class no longer resolves#783julik wants to merge 1 commit into
julik wants to merge 1 commit into
Conversation
…olves If an ActiveJob class with limits_concurrency is renamed or removed between deploys, any BlockedExecution rows referencing the old class name would cause the dispatcher's concurrency-maintenance tick to raise DelegationError forever: release -> acquire_concurrency_lock -> Semaphore.wait -> job.concurrency_limit, which delegates to a nil job_class. Guard the release path (symmetric with Job#acquire_concurrency_lock) and short-circuit set_expires_at with the default concurrency period when the class is unresolvable.
julik
marked this pull request as ready for review
August 1, 2026 20:07
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.
Fixes #784.
Summary
Fixes a
DelegationErrorraised on everySolidQueue::Dispatcher::ConcurrencyMaintenancetick when aBlockedExecutionrow references aJobwhoseclass_nameno longersafe_constantizes — e.g. because the concurrency-limited ActiveJob class was renamed or removed between deploys.Job#acquire_concurrency_lockalready gates onconcurrency_limited?(which checksjob_class.present?), butBlockedExecution#acquire_concurrency_lock— invoked from the dispatcher-driven release path — went straight toSemaphore.wait(job), which callsjob.concurrency_limit, which is delegated to aniljob_class:Because the exception is raised inside
BlockedExecution#release's transaction, the row is never destroyed or promoted, and the dispatcher re-picks the same orphans forever — flooding error reporters and starving any legitimately blocked jobs that share the concurrency key.Changes
BlockedExecution#release: ifjob.job_classisnil, destroy the orphan row and emitorphaned: truein therelease_blockedinstrumentation payload. Otherwise fall through to the existing acquire/promote/destroy path.BlockedExecution#set_expires_at: fall back toSolidQueue.default_concurrency_control_periodwhen the class does not resolve (guards the same latent bug at create time).Job#job_classpromoted from private to public soBlockedExecutioncan consult it.Test plan
bin/rails test test/models/solid_queue/blocked_execution_test.rb— new test passes.bin/rails test test/models/— full model suite green (97 runs, 585 assertions, 0 failures).