You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
move-queue leaves jobs stranded on the old queue, and re-running it refuses #187
Came in with 4a5da1e (the new move-queue command).
taskq actor-config move-queue drains the backlog in batches and then flips the assignment (actor_config_ops.py:412). The drain only sees jobs that exist at drain time. After it, more of the actor's jobs still land on the old queue:
jobs that were running during the move and later retry or snooze (retry and snooze don't rewrite queue)
an admin retry of a failed job from before the move
any enqueue, from a producer or a cron tick, that commits between the last drain batch and the flip
after the flip, stale producers still using the old literal, plus cron ticks that read the assignment before the flip
Cron fires planned after the flip read the stored assignment (cron_loop.py:760), so those go to the new queue. I only traced the cron path in code and didn't run it.
The docs promise "old-queue strays drain through the target's consumers" (workers.md:680, cli.md:346), and say to stop consuming the old queue once producers are updated. They never mention retries, snoozes or admin retries landing on the old queue. Operators who follow the docs leave these jobs sitting there unclaimed. Re-running the move to sweep them exits with "already assigned to queue ... a move onto the same queue is a no-op" (actor_config_ops.py:496), and no other command rewrites jobs.queue.
Reproduced twice against Postgres with the production dispatch, retry, snooze, admin-retry and enqueue calls. The move drained 3 jobs. After that the running job's retry and snooze both ended up scheduled on the old queue, the admin retry landed pending on the old queue, and an enqueue forced into the drain-to-flip window stayed pending on the old queue. A consumer of only the new queue claimed the 3 drained jobs and none of the others. Re-running the move raised, and the CLI exited 2 with the message above. The jobs still exist, and a worker that serves the old queue again does pick them up.
Probably wants: rewrite queue on retry, snooze and requeue from the stored assignment (or have dispatch accept strays), and let a same-queue re-run sweep leftovers instead of refusing. Fix the docs either way.
Verified against current code on redteam/issue-sweep-post-203 (HEAD 8552a1e) — this does not reproduce. It was fixed by 3fbe36d ("assignment-routed re-pend tails"), before this issue's sweep pass ever ran, and is separately watched by .shipwright/initiatives/I-04/spec.md criterion 46.
What changed since the report:
src/taskq/actor_config_ops.py:429 (move_actor_queue) still drains the backlog in bounded batches then flips the stored assignment in one final transaction, exactly as before. What's different is the dispatch side.
src/taskq/backend/_dispatch_sql.py:77-103 documents and implements a routing contract: a pending row whose started_at IS NULL (never claimed) routes by its own jobs.queue label — producer placement governs, so a stale producer's post-move enqueue is a documented, deliberate residual served by the retired queue's consumers. But a row that has been claimed at least once (started_at IS NOT NULL) — i.e. every re-pend path: mark_failed_or_retry's backoff, the leader's lease-expiry reclaim sweep, the operator's retry_job, and the snooze/refund deferral arms — routes at dispatch by the actor's current stored assignment (actor_config.queue), not by the row's own stale queue label. The label itself is left unrewritten (it's kept as an audit trail of first placement), but dispatch candidacy no longer depends on it once the row has been claimed.
Cron fires read actor_config.queue fresh on every tick (src/taskq/worker/cron_loop.py:752-757), so schedules fire onto the new queue from the flip onward with no separate fix needed.
Reproduction and its result, run against real Postgres (module_pg_schema, production mark_failed_or_retry/retry_job/dispatch/sweep code paths, no mocks): tests/test_rt_actor_queue_move.py, class TestRunningJobTail. Each test moves an actor with one already-running job, drives the row through a different re-pend path, and asserts which queue's consumers can claim the tail:
test_failure_retry_tail_is_served_only_by_the_retired_source_queue — worker-side transient-failure retry (backoff) lands the row back in pending still labeled with the old queue, but the target queue's consumers claim it (claimed_new == 1, claimed_old == 0).
test_lease_expiry_reclaim_tail_is_served_only_by_the_retired_source_queue — the leader's crash-reclaim sweep (sweep_expired_locks) re-pends the row on the old label; same result, target consumers claim it.
test_operator_retry_tail_is_served_only_by_the_retired_source_queue — a terminally-failed left-behind job re-armed via the operator's retry_job; same result.
All three (and the full file) are green now:
uv run --no-sync pytest tests/test_rt_actor_queue_move.py -q
7 passed, 1 warning in 4.05s
TestSourceQueueStray::test_post_move_producer_stray_is_served_by_a_source_queue_consumer pins the one residual the feature still documents and intends to keep: a stale producer's post-flip enqueue to the literal old-queue name is served by that queue's own consumers, never by the target's — this is the carve-out the docstring calls out, distinct from the running-job tail this issue was about, and operators are told in the CLI's own post-move note to keep old-queue consumers alive until every producer is updated.
On the re-run-refuses complaint: a same-queue re-run still raises (actor_config_ops.py:529-533), but it's no longer needed to sweep leftovers — the running-job tail now drains automatically through the target's consumers via the dispatch routing contract above, so there is nothing stranded for a re-run to sweep. TestMidDrainAbort::test_mid_drain_abort_is_re_runnable_but_leaves_partial_progress_unreported additionally pins that a move aborted partway through the drain (e.g. a row lock forcing a statement-timeout cancellation) is safely re-runnable and resumes from the committed partial progress rather than restarting or double-moving rows.
Operator impact: none currently — a move-queue operator no longer needs to keep the old queue's consumers running to catch retries/reclaims/admin-retries; only genuinely stale producers (not yet redeployed with the new queue literal) still need the old queue served, matching what the CLI's own post-move message already tells them.
Disposition: closing as already fixed, with the above passing test as evidence.
Activity
rcbevans commentedon Sep 15, 2026
Verified against current code on
redteam/issue-sweep-post-203(HEAD8552a1e) — this does not reproduce. It was fixed by3fbe36d("assignment-routed re-pend tails"), before this issue's sweep pass ever ran, and is separately watched by.shipwright/initiatives/I-04/spec.mdcriterion 46.What changed since the report:
src/taskq/actor_config_ops.py:429(move_actor_queue) still drains the backlog in bounded batches then flips the stored assignment in one final transaction, exactly as before. What's different is the dispatch side.src/taskq/backend/_dispatch_sql.py:77-103documents and implements a routing contract: a pending row whosestarted_at IS NULL(never claimed) routes by its ownjobs.queuelabel — producer placement governs, so a stale producer's post-move enqueue is a documented, deliberate residual served by the retired queue's consumers. But a row that has been claimed at least once (started_at IS NOT NULL) — i.e. every re-pend path:mark_failed_or_retry's backoff, the leader's lease-expiry reclaim sweep, the operator'sretry_job, and the snooze/refund deferral arms — routes at dispatch by the actor's current stored assignment (actor_config.queue), not by the row's own stalequeuelabel. The label itself is left unrewritten (it's kept as an audit trail of first placement), but dispatch candidacy no longer depends on it once the row has been claimed.actor_config.queuefresh on every tick (src/taskq/worker/cron_loop.py:752-757), so schedules fire onto the new queue from the flip onward with no separate fix needed.Reproduction and its result, run against real Postgres (
module_pg_schema, productionmark_failed_or_retry/retry_job/dispatch/sweep code paths, no mocks):tests/test_rt_actor_queue_move.py, classTestRunningJobTail. Each test moves an actor with one already-running job, drives the row through a different re-pend path, and asserts which queue's consumers can claim the tail:test_failure_retry_tail_is_served_only_by_the_retired_source_queue— worker-side transient-failure retry (backoff) lands the row back inpendingstill labeled with the old queue, but the target queue's consumers claim it (claimed_new == 1,claimed_old == 0).test_lease_expiry_reclaim_tail_is_served_only_by_the_retired_source_queue— the leader's crash-reclaim sweep (sweep_expired_locks) re-pends the row on the old label; same result, target consumers claim it.test_operator_retry_tail_is_served_only_by_the_retired_source_queue— a terminally-failed left-behind job re-armed via the operator'sretry_job; same result.All three (and the full file) are green now:
TestSourceQueueStray::test_post_move_producer_stray_is_served_by_a_source_queue_consumerpins the one residual the feature still documents and intends to keep: a stale producer's post-flip enqueue to the literal old-queue name is served by that queue's own consumers, never by the target's — this is the carve-out the docstring calls out, distinct from the running-job tail this issue was about, and operators are told in the CLI's own post-move note to keep old-queue consumers alive until every producer is updated.On the re-run-refuses complaint: a same-queue re-run still raises (
actor_config_ops.py:529-533), but it's no longer needed to sweep leftovers — the running-job tail now drains automatically through the target's consumers via the dispatch routing contract above, so there is nothing stranded for a re-run to sweep.TestMidDrainAbort::test_mid_drain_abort_is_re_runnable_but_leaves_partial_progress_unreportedadditionally pins that a move aborted partway through the drain (e.g. a row lock forcing a statement-timeout cancellation) is safely re-runnable and resumes from the committed partial progress rather than restarting or double-moving rows.Operator impact: none currently — a
move-queueoperator no longer needs to keep the old queue's consumers running to catch retries/reclaims/admin-retries; only genuinely stale producers (not yet redeployed with the new queue literal) still need the old queue served, matching what the CLI's own post-move message already tells them.Disposition: closing as already fixed, with the above passing test as evidence.