Repository navigation
fix: batch-mode pause, weighted batch claim loss, undecodable rows in the reaper and MySQL claims - #93
Merged
Conversation
… claims The stale job reaper decoded every reclaimed row (MySQL) or every row out of attempts (PostgreSQL) and failed the whole pass on one it could not decode, so no stale job was reclaimed while that row existed. It now reclaims such rows from their raw columns and skips only the side effects that need the decoded job. MySQL claims left an undecodable row Pending at the head of its queue, so single claims failed on it forever and batch claims of one job came back empty. They now claim it like PostgreSQL does, so the queue moves on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a later level fails dequeue_batch_leased with weighted priorities claims one level at a time, each claim committing on its own. An error claiming a later level was returned with `?`, dropping the jobs claimed from earlier levels: they stayed Running until their leases expired, with an attempt spent, so a job on its last attempt went Dead without running. Both backends now share fill_weighted_batch, which returns the claimed jobs and logs the error, as the trait's default implementation already did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A batch-mode worker checked the pause only when claiming, then started every job of the batch it held, so pausing a queue let up to batch_size more jobs start. Before starting a held job it now checks the pause at most once per poll interval and, if the queue is paused, releases the unstarted jobs with release_job_run (no attempt counted), as it does on shutdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
Merged
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.
Four bugs found in an adversarial pass over the code added since 2.0.0 (batch claims and batch-mode workers) and its interactions. Each fix has a regression test that fails without it. All fixes are non-breaking and target a 2.1.x patch release.
Bugs fixed
1. Pausing a queue doesn't stop a batch-mode worker from starting the jobs it holds (medium)
Worker::run_batch_until_donechecked the pause only at claim time, then started every job of the batch it held. Pausing a queue therefore let up tobatch_sizemore jobs start, which contradicts the docs ("paused queues are honoured").Fix: before starting a held job, the worker checks the pause, at most once per poll interval. If the queue is paused, it hands the unstarted jobs back with
release_job_run, without counting an attempt, as it does on shutdown. Running jobs finish. The worker docs anddocs/batch-operations.mddescribe the new behaviour.Test:
batch_dequeue_tests::worker::{postgres,mysql}_tests::pause_releases_unstarted_jobs. Without the fix it fails on both backends withtimed out waiting for 2 Pending jobs: {"Completed": 1, "Running": 2}.2. A weighted batch claim drops the jobs it already claimed when a later level fails (medium)
With weighted priorities,
dequeue_batch_leasedclaims one priority level at a time, and each claim commits separately. If a later level's claim failed (a dropped connection, or a MySQL deadlock past its retries),?returned the error and dropped the jobs claimed from earlier levels. Those jobs stayedRunninguntil their leases expired, with an attempt spent, so a job on its last attempt went toDeadwithout ever running. The trait's default implementation already documented and did the right thing.Fix: both backends now share
queue::fill_weighted_batch. It returns the jobs already claimed and logs the error. If nothing was claimed, it still returns the error.Test: the unit test
queue::tests::weighted_batch_keeps_claimed_jobs_when_a_later_claim_fails. It fails when the?behaviour is restored.3. One undecodable row stops the stale job reaper for every queue (medium)
A row the library can't decode stops
requeue_stale_jobsentirely: no stale job is reclaimed anywhere while that row exists. Such rows come from corrupt data, or from a newer version's data during a rolling upgrade (for example, aretry_strategyvariant this version doesn't know).into_job()?on every candidate, so the error rolled back the whole pass.Fix: the reaper reclaims these rows from their raw columns. For a Dead row it skips only the side effects that need the decoded job, and logs a warning saying so.
Test:
undecodable_row_tests::{postgres,mysql}_reaper_reclaims_undecodable_rows. Without the fix,requeue_stale_jobsreturns an error on both backends.4. An undecodable row blocks a MySQL queue forever (medium)
MySQL left an undecodable row
Pendingat the head of its queue. Every single claim failed on it, and a batch claim of one job came back empty forever, so nothing behind it ever ran. PostgreSQL instead claims such a row: it staysRunninguntil its lease expires, then the reaper handles it, so the queue keeps moving.Fix: MySQL single and batch claims now claim the row too, matching PostgreSQL. A single claim returns the decoding error after the claim commits; a batch claim skips the row and logs it.
Test:
undecodable_row_tests::{postgres,mysql}_undecodable_rows_do_not_block_claims. It fails on MySQL without the fix.Verification
cargo test --workspace --all-features --no-fail-fast -- --include-ignored --skip mysql: 1954 passed, 0 failed.--include-ignored mysql, with both URLs pointing at MySQL: 198 passed, 0 failed.cargo test -p hammerwork --docpasses.cargo fmt --all --checkandcargo clippy --workspace --all-targets --all-features --locked -- -D warningsare clean, as is the feature-combination clippy for every CI matrix entry.🤖 Generated with Claude Code