fix: queue-storage cancel_by_unique_key for running jobs (cut 0.6.0-rc.4)#359
Conversation
The candidate lookup's running-job branch read `unique_key` directly
from `{schema}.leases`, but the `leases` table carries no `unique_key`
column, so any `cancel_by_unique_key` / `cancel_by_unique_key_tx`
issued while queue storage was the active engine failed at plan time
with `column "unique_key" does not exist`.
Recover the key by joining each lease back to its originating
`ready_entries` row, the same lane-identity join already used by the
queue-storage jobs-compat view. Canonical-engine behaviour is
unchanged.
Add a queue-storage-active regression test covering both the pool and
transaction entry points; it fails at plan time before this change.
|
Warning Review limit reached
Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
On the queue-storage engine,
admin::cancel_by_unique_keyandcancel_by_unique_key_txfailed at plan time with:so cancel-by-unique-key was unusable whenever queue storage was the active engine. The canonical engine was unaffected — it uses a separate candidate query against
jobs_hot/scheduled_jobs.Root cause
unique_key_candidate_sqlunions three lookups — available (ready_entries), deferred (deferred_jobs), and running (leases). The running-job branch readleases.unique_key, but theleasessubstrate table has nounique_keycolumn (onlyready_entries,deferred_jobs, anddone_entriescarry it). PostgreSQL rejects the whole statement during planning, independent of whether any row matches.Fix
Recover the running job's key by joining each lease back to its originating
ready_entriesrow via the lane identity (ready_slot, ready_generation, queue, priority, enqueue_shard, lane_seq) — the same joinqueue_storage_current_jobs_ctealready uses — and matchready.unique_key.Test
New
test_admin_cancel_by_unique_key_queue_storage_activeactivates the queue-storage engine and exercises both the pool and transaction entry points, assertingOk(None)when nothing matches. It reproduces the failure (column "unique_key" does not exist) on the pre-fix code and passes after. Fullintegration_testsuite green (44 tests);fmt/clippy -D warnings/buildclean.Cuts
0.6.0-rc.4.