-
Notifications
You must be signed in to change notification settings - Fork 75
fix(transaction): move flag assignment after auto-commit #426
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
base: main
Are you sure you want to change the base?
Conversation
Set last_update_committed_ before calling Commit(), but revert the flag if auto-commit fails. This ensures: 1. Commit() can proceed (it requires last_update_committed_ == true) 2. If commit fails, the flag is reverted to false 3. Transaction state remains consistent on failure
9cc0948 to
17c03f1
Compare
| update->ApplyTo(*metadata_builder_); | ||
| } | ||
|
|
||
| last_update_committed_ = true; |
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.
Perhaps it is simpler to move line 68 to be after the if (auto_commit_) block?
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.
make sense! it makes simpler.
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.
It seems the test failed after we move this line. The problem is Commit() requires this flag to be true at the start. So we need to set it to be true before that.
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 think the name last_update_committed_ might confuse readers a little bit because it only means whether previous created pending update has called commit to apply changes to the transaction. We use this flag to make sure updates are created and committed sequentially to make the state of transaction simpler. Since it has nothing to do with the transaction object itself, I'm hesitant to set last_update_committed_ to false when transaction.Commit fails. Perhaps we should rename it to last_update_applied or something more precise. WDYT?
Simplifies the Apply() method by moving the flag assignment to after the auto-commit conditional block. This eliminates the need to revert the flag on commit failure while maintaining the same behavior.
…mode The previous refactor moved the flag assignment after the auto_commit block, but Commit() requires this flag to be true. This caused test failures with 'Cannot commit transaction when previous update is not committed' error. The fix: - Set last_update_committed_ = true before calling Commit() - On Commit() failure, revert the flag to false - This maintains exception safety while allowing Commit() to proceed
Move last_update_committed_ assignment to after auto-commit attempt.
If Commit() fails, ICEBERG_RETURN_UNEXPECTED returns early and the flag remains false, preventing the transaction from incorrectly reporting the update as committed when it actually failed.