diff options
Diffstat (limited to 'src')
5 files changed, 6 insertions, 52 deletions
diff --git a/src/mongo/db/catalog/validate_state.cpp b/src/mongo/db/catalog/validate_state.cpp index 3b1b6db8764..120325051ef 100644 --- a/src/mongo/db/catalog/validate_state.cpp +++ b/src/mongo/db/catalog/validate_state.cpp @@ -174,27 +174,8 @@ void ValidateState::_yieldCursors(OperationContext* opCtx) { _seekRecordStoreCursor->save(); if (isBackground() && _validateTs) { - // End current transaction and begin a new one, to help ameliorate WiredTiger cache - // pressure. - - // First, move all cursor objects off our operation context, which has the effect of closing - // all storage engine cursors in the active transaction. - for (const auto& indexCursor : _indexCursors) { - indexCursor.second->detachFromOperationContext(); - } - _traverseRecordStoreCursor->detachFromOperationContext(); - _seekRecordStoreCursor->detachFromOperationContext(); - - // This begins a new transaction and then ends the current transaction, in order to preserve - // the history required to construct the same snapshot as before. + // Reset snapshot to help ameliorate WiredTiger cache pressure. opCtx->recoveryUnit()->refreshSnapshot(); - - // Move the cursor objects back in preparation for restoring. - for (const auto& indexCursor : _indexCursors) { - indexCursor.second->reattachToOperationContext(opCtx); - } - _traverseRecordStoreCursor->reattachToOperationContext(opCtx); - _seekRecordStoreCursor->reattachToOperationContext(opCtx); } // Restore all the cursors. diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h index 80156daeb72..5dcfec7a548 100644 --- a/src/mongo/db/storage/recovery_unit.h +++ b/src/mongo/db/storage/recovery_unit.h @@ -413,8 +413,7 @@ public: } /** - * Refreshes a read transaction by starting a new one at the same read timestamp and then ending - * the current one. + * Refreshes a read transaction by resetting the snapshot in use */ virtual void refreshSnapshot() {} diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.cpp index 6a8276afe3e..0954cdb7ddc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.cpp @@ -67,9 +67,6 @@ WiredTigerBeginTxnBlock::WiredTigerBeginTxnBlock( } builder << "),"; } - if (roundUpReadTimestamp == RoundUpReadTimestamp::kNoRoundForce) { - builder << "read_before_oldest=true,"; - } const std::string beginTxnConfigString = builder; invariantWTOK(_session->begin_transaction(_session, beginTxnConfigString.c_str()), _session); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.h b/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.h index 39574968ae9..458038db507 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_begin_transaction_block.h @@ -48,8 +48,6 @@ public: // Whether or not to round up to the oldest timestamp when the read timestamp is behind it. enum class RoundUpReadTimestamp { kNoRoundError, // Do not round to the oldest timestamp. BadValue error may be returned. - kNoRoundForce, // Do not round to the oldest timestamp. Reading older than the oldest - // timestamp is permitted with no error. kRound // Round the read timestamp up to the oldest timestamp when it is behind. }; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index e14c82ccb91..ab435ba9e09 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -372,10 +372,6 @@ void WiredTigerRecoveryUnit::preallocateSnapshotForOplogRead() { } void WiredTigerRecoveryUnit::refreshSnapshot() { - // First, start a new transaction at the same timestamp as the current one. Then end the - // current transaction. This overlap will prevent WT from cleaning up history required to serve - // the read timestamp. - // Currently, this code only works for kNoOverlap or kNoTimestamp. invariant(_timestampReadSource == ReadSource::kNoOverlap || _timestampReadSource == ReadSource::kNoTimestamp); @@ -384,27 +380,10 @@ void WiredTigerRecoveryUnit::refreshSnapshot() { invariant(!_noEvictionAfterRollback); invariant(_abandonSnapshotMode == AbandonSnapshotMode::kAbort); - auto newSession = _sessionCache->getSession(); - WiredTigerBeginTxnBlock txnOpen(newSession->getSession(), - _prepareConflictBehavior, - _roundUpPreparedTimestamps, - RoundUpReadTimestamp::kNoRoundForce); - if (_timestampReadSource != ReadSource::kNoTimestamp) { - auto status = txnOpen.setReadSnapshot(_readAtTimestamp); - fassert(5035300, status); - } - txnOpen.done(); - - // Now end the previous transaction. - auto wtSession = _session->getSession(); - auto wtRet = wtSession->rollback_transaction(wtSession, nullptr); - invariantWTOK(wtRet, wtSession); - LOGV2_DEBUG(5035301, - 3, - "WT begin_transaction & rollback_transaction", - "snapshotId"_attr = getSnapshotId().toNumber()); - - _session = std::move(newSession); + auto session = _session->getSession(); + invariantWTOK(session->reset_snapshot(session), session); + LOGV2_DEBUG( + 6235000, 3, "WT refreshed snapshot", "snapshotId"_attr = getSnapshotId().toNumber()); } void WiredTigerRecoveryUnit::_txnClose(bool commit) { |