fix(replays): stop bulk delete progress stalling and rewinding - #120772
fix(replays): stop bulk delete progress stalling and rewinding#120772JoshuaKGoldberg wants to merge 4 commits into
Conversation
Task delivery is at-least-once, so a job can have more than one live call chain: a redelivered activation re-enters at the offset it was given while the successor it already enqueued keeps going. Both chains wrote the whole row via save(), so the reported count rotated between their two positions and a stale chain could revert a terminal status. Progress and status are now written per-column, the offset only moves forward, and a chain that fell behind the checkpoint exits instead of re-deleting rows. A blown processing deadline raises a BaseException, so it bypassed the task's exception handler, and the broker discards the activation once retries run out. That left the job reporting in-progress forever with nothing to advance it. It now reaches a terminal failed status on the last attempt. Deleting a batch's recordings used a fresh thread pool per replay, serializing the batch behind whichever replay had the most segments. Locally a 100-replay batch took 5.4s where one shared pool takes 0.07s, which is what pushed batches past the 600s deadline. The batch now shares one pool. Refs #120413
|
@cursor review |
The guard exited early when an activation arrived behind the checkpoint, on the assumption that another chain was already ahead of it. But the checkpoint is written before the successor is enqueued, so an activation killed in that gap came back, saw itself behind, and returned without enqueueing anything or moving the status. That stranded the job at in-progress, which is the failure this PR is meant to remove. The guard was not load-bearing: the monotonic offset write already makes the counter immune to a lagging chain, and reproducing the two-chain interleaving without the guard yields the identical sequence. A duplicate chain now just redoes idempotent work instead of being suppressed. Reported by Cursor Bugbot on #120772.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 04e2dba. Configure here.
| # namespace="replays") continue to resolve and execute. | ||
| alias_namespace=replays_tasks, | ||
| retry=Retry(times=5), | ||
| retry=Retry(times=5, on=(ProcessingDeadlineExceeded,)), |
There was a problem hiding this comment.
Retry policy drops exception recovery
Medium Severity
Narrowing retry to only ProcessingDeadlineExceeded drops retries for ordinary exceptions, but _advance_offset, status completion, and the next .delay() still sit outside the try/except that marks the job failed. A transient DB or enqueue error after a successful batch can leave the job stuck in-progress with nothing left to advance it.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 04e2dba. Configure here.
There was a problem hiding this comment.
Errm. I think this is already the case on master? Someone please tell me if I'm wrong.


Bulk replay delete jobs showed two counter symptoms in production:
Count Deletedfrozen at a value for hours while the job still reportedin-progress: fixed by pooling recording deletes once per batch rather than per replay, and by marking the job as'failed'on the final attempt.Closes #120413.