From ce0d373f2225bc320d6796ff262c1ab038dd780a Mon Sep 17 00:00:00 2001 From: Handora Date: Fri, 9 Feb 2024 15:32:30 +0000 Subject: [PATCH] BUG] calculate checksum when recovered checksum is 0 --- src/storage/memtable/mvcc/ob_tx_callback_list.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/storage/memtable/mvcc/ob_tx_callback_list.cpp b/src/storage/memtable/mvcc/ob_tx_callback_list.cpp index 3ab017fe11..f9cbe71686 100644 --- a/src/storage/memtable/mvcc/ob_tx_callback_list.cpp +++ b/src/storage/memtable/mvcc/ob_tx_callback_list.cpp @@ -579,8 +579,14 @@ int ObTxCallbackList::tx_calc_checksum_before_scn(const SCN scn) int ObTxCallbackList::tx_calc_checksum_all() { int ret = OB_SUCCESS; - if (OB_UNLIKELY(checksum_scn_.is_max())) { - // skip repeate calc checksum + if (OB_UNLIKELY(checksum_scn_.is_max() && + 0 != checksum_)) { + // There could be a scenario where, under the condition that checksum_scn is + // persisted at its maximum value, while checksum_ might be 0. In such a + // scenario, we still rely on calculating the checksum to prevent mistakenly + // using 0 for checksum verification and avoid potential errors. + // + // skip the unnecessary repeate calc checksum } else { LockGuard guard(*this, LOCK_MODE::LOCK_ALL); ObCalcChecksumFunctor functor; @@ -705,6 +711,7 @@ int ObTxCallbackList::replay_fail(const SCN scn, const bool serial_replay) void ObTxCallbackList::get_checksum_and_scn(uint64_t &checksum, SCN &checksum_scn) { LockGuard guard(*this, LOCK_MODE::LOCK_ITERATE); + if (checksum_scn_.is_max()) { checksum = checksum_; checksum_scn = checksum_scn_;