Repository navigation
Conversation
Keep transactional checkpoints out of deferred attempt metadata after successful writes so a later failure cannot persist progress whose application transaction rolls back. Preserve earlier deferred progress when the checkpoint write itself fails. Follow Ruby's rule that the transaction owns a successful write, allowing earlier unpersisted steps to run again after rollback. Persist cursor changes independently of completed steps so a failed first step can resume from its cursor. Retain Rust and JavaScript progress on snooze and other incomplete outcomes, including in worker helpers, and align Java's cursor behavior with the other runtimes. Cover rollback, commit followed by failure, failed writes, subsequent cursor changes, first-step retries, snooze, and cooperative shutdown with regressions and shared conformance scenarios.
bgentry
force-pushed
the
bg/fix-resumable-progress
branch
from
October 20, 2026 13:20
74e3217 to
d761ae5
Compare
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.
Resumable jobs save completed steps and cursors so retries can skip finished work. This PR fixes three bugs that made retries skip work that never committed or repeat work already done.
1. Retries can skip work that rolled back. River normally saves progress from memory when an attempt ends. Transactional helpers write a checkpoint immediately, inside the worker’s transaction. That checkpoint must commit or roll back with the application changes.
In Go,
ResumableSetStepTxandResumableSetStepCursorTxalso added the checkpoint to memory before their database write succeeded. Their Rust equivalents and JavaScript’sresumable.checkpointhad the same bug. A worker could update a customer row’s address and save the customer’s ID as a cursor in the job’s metadata, all in one transaction. If the transaction rolled back, River still saved the cursor with the failed attempt. The retry then skipped that customer even though the address update never committed. A failed checkpoint write could cause the same bug.The fix has to work without knowing how the transaction ends: River cannot see whether a caller-owned transaction later commits or rolls back. If the attempt's final update saved the checkpoint, it could restore one that rolled back. If it saved only the earlier progress, it could overwrite one that committed. So after a successful checkpoint write, the final update saves neither. It saves only progress recorded after that write. A failed checkpoint write leaves pending progress unchanged.
The cost is that a rollback can make the retry repeat earlier steps whose progress existed only in memory. Ruby already works this way. Suppose
preparecompletes beforeimportcheckpoints cursor1, with no previously saved progress:prepare; startsimportwithout a cursorprepare; resumesimportat cursor1prepare; startsimportwithout a cursor2. A cursor in the first step is lost. A cursor records progress within an unfinished step. Go, Rust, JavaScript, and Java saved cursors only when at least one step had completed.
If the first step processed items 1–7, recorded cursor
7, and failed, the retry received no cursor and repeated those items.River now saves cursors independently of step completion. The retry receives cursor
7so it can continue with item 8. This also preserves cursors on snooze and cooperative shutdown.3. Snoozing drops progress in Rust and JavaScript. Snoozing ends the attempt and schedules another run. Both runtimes treated snooze as a successful worker return, but saved progress only on error. A worker that completed
downloadand snoozed beforetransformtherefore downloaded everything again.Both runtimes now save progress unless the job completed, matching Go and Ruby. Their worker test helpers follow the same rule.
Shared conformance cases cover these behaviors, including failed checkpoint writes and progress recorded after a checkpoint.
Not addressed here: