Repository navigation
Conversation
The commit xid of a transaction is allocated from the same counter as trx ids, but log replay only advanced the counter with the trx ids in the log entry headers. When a transaction commits after another transaction has started, its commit xid is larger than every trx id in the log, so a transaction started after recovery could get a smaller id and could not see the records committed before the crash. This can make MvccTrxLog.wal_rollback_abnormal count 499 visible records instead of 500. Fixes oceanbase#442
This branch has not been deployed
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.
What problem were solved in this pull request?
Issue Number: close #442
Problem:
MvccTrx::commit()takes its commit xid from the same counter as transaction ids (MvccTrxKit::next_trx_id()), and a committed record stores it as itsbegin_xid. During recovery the counter is only advanced with the trx ids in the log entry headers (MvccTrxKit::create_trx(log_handler, trx_id)); thecommit_trx_idof a commit log entry is ignored.If a transaction commits after another transaction has started, its commit xid is larger than every trx id in the log. After recovery a new transaction can get an id smaller than that commit xid, and
MvccTrx::visit_recordtreats the committed record as invisible (trx_id_ >= begin_xidis false).Example: trx 1 and trx 2 start, then commit with xids 3 and 4. After recovery the counter is 2, so a new transaction gets id 3 and cannot see the record committed with xid 4.
MvccTrxLog.wal_rollback_abnormalcan hit this when, at the end of its concurrent run, two transactions commit after the last transaction started: one transaction's records are then invisible after recovery and the test counts 499 instead of 500, which is the failure reported in #442. It failed exactly this way on #650: https://github.com/oceanbase/miniob/actions/runs/38174840520/job/114575201900What is changed and how it works?
MvccTrxKit::update_trx_id(), which raises the trx id counter to at least the given id.commit_trx_id.MvccTrxLog.wal_trx_id_after_recovery, a single-threaded test of the example above. It fails without this change (1 of 2 committed records visible) and passes with it.Other information
mvcc_trx_log_testfailure on fix: return the constant instead of the first child when simplifying conjunctions #650.MvccTrxLogtests abort on my machine (12 cores, GCC 15) with assertion / ASAN errors in the storage layer during their concurrent insert phase, both with and without this change, so I am relying on CI for them.