-
Notifications
You must be signed in to change notification settings - Fork 123
sweepbatcher: persist confirmed batches atomically #1044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
hieblmi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change LGTM!
Could we just check that this couldn't happen in other places where we call b.persist(ctx)?
| "purged swaps: %v. Saving the batch and sweeps to DB", | ||
| confirmedSweeps, purgedSweeps, purgedSwaps) | ||
|
|
||
| if err := b.persistConfirmedBatch(ctx, dbConfirmed); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, now both batch and sweeps are persisted at the same time!
Can we make sure that in other places where we call b.persist(ctx) there doesn't arise this discrepancy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-checked all other places. This is the only one when a batch and a sweep are mutated simultaneously. Also double-checked with AI - no other findings.
bhandras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
Fixes a crash window where handleConf updated the batch row to confirmed but failed before marking sweeps complete, so re-added sweeps spawned a duplicate batch or kept retrying. Batch confirmation and sweep completion are now persisted inside a single DB transaction ConfirmBatchWithSweeps, and handleConf uses the helper to atomically store the batch and the set of confirmed sweeps. Added TestSweepBatcherConfirmedBatchIncompleteSweeps that runs against the real loopdb backend, injects a failure mid-transaction, and verifies the database never ends up with confirmed=true batches paired with completed=false sweeps.
1beb6b9 to
6d58965
Compare
|
Rebased |
hieblmi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes a crash window where
handleConfupdated the batch row to confirmed but failed before marking sweeps complete, so re-added sweeps spawned a duplicate batch or kept retrying. Batch confirmation and sweep completion are now persisted inside a single DB transactionConfirmBatchWithSweeps, andhandleConfuses the helper to atomically store the batch and the set of confirmed sweeps.Added
TestSweepBatcherConfirmedBatchIncompleteSweepsthat runs against the realloopdbbackend, injects a failure mid-transaction, and verifies the database never ends up with confirmed=true batches paired with completed=false sweeps.Pull Request Checklist
release_notes.mdif your PR contains major features, breaking changes or bugfixes