Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the MVCC (Multi-Version Concurrency Control) commit logic to reduce code duplication and adds correctness assertions. The PR depends on #5596 which added initial MVCC correctness asserts, and this PR continues that work with additional refactoring.
Changes:
- Extracted common read-only transaction commit logic into
commit_read_only_txhelper function - Extracted version timestamp conversion logic into
convert_version_timestampshelper function - Added runtime assertions to enforce MVCC invariants (transactions not depending on themselves, proper timestamp ordering)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extract commit_read_only_tx() to unify the read-only transaction commit logic used by both the Initial fast-path and the WaitForDependencies path. The WaitForDependencies path previously called pager_commit_lock.unlock() directly inside the is_exclusive_tx guard, while Initial used unlock_commit_lock_if_held(). Both were correct (exclusive txs always hold the commit lock), but the helper is used now for consistency.
Deduplicate the TxID-to-Timestamp conversion loops for table rows and index rows during commit postprocessing. The same logic (match begin/end against tx_id, replace with Timestamp, append to log_record, check sqlite_schema) was repeated for both row types.
b1168e4 to
3da55d6
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.
Description
Depends on #5596