diff options
5 files changed, 27 insertions, 31 deletions
diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index 9686085111d..dcdb4347782 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -550,6 +550,10 @@ public: * all_durable timestamp are committed. Only storage engines that support document level locking * must provide an implementation. Other storage engines may provide a no-op implementation. * + * The all_durable timestamp is the in-memory no holes point. That does not mean that there are + * no holes behind it on disk. The all_durable timestamp also might not correspond with any + * oplog entry, but instead have a timestamp value between that of two oplog entries. + * * The all_durable timestamp only includes non-prepared transactions that have been given a * commit_timestamp and prepared transactions that have been given a durable_timestamp. * Previously, the deprecated all_committed timestamp would also include prepared transactions diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 97380b509e8..c55321865c3 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -2191,8 +2191,28 @@ StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp(OperationCont return {stableTimestamp}; } +namespace { +uint64_t _fetchAllDurableValue(WT_CONNECTION* conn) { + // Fetch the latest all_durable value from the storage engine. This value will be a timestamp + // that has no holes (uncommitted transactions with lower timestamps) behind it. + char buf[(2 * 8 /*bytes in hex*/) + 1 /*nul terminator*/]; + auto wtstatus = conn->query_timestamp(conn, buf, "get=all_durable"); + if (wtstatus == WT_NOTFOUND) { + // Treat this as lowest possible timestamp; we need to see all preexisting data but no new + // (timestamped) data. + return StorageEngine::kMinimumTimestamp; + } else { + invariantWTOK(wtstatus); + } + + uint64_t tmp; + fassert(38002, NumberParser().base(16)(buf, &tmp)); + return tmp; +} +} // namespace + Timestamp WiredTigerKVEngine::getAllDurableTimestamp() const { - auto ret = _oplogManager->fetchAllDurableValue(_conn); + auto ret = _fetchAllDurableValue(_conn); stdx::lock_guard<Latch> lk(_highestDurableTimestampMutex); if (ret < _highestSeenDurableTimestamp) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp index 72e0e2103a7..3de35d2ba62 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp @@ -225,7 +225,7 @@ void WiredTigerOplogManager::_updateOplogVisibilityLoop(WiredTigerSessionCache* // Fetch the all_durable timestamp from the storage engine, which is guaranteed not to have // any holes behind it in-memory. - const uint64_t newTimestamp = fetchAllDurableValue(sessionCache->conn()); + const uint64_t newTimestamp = sessionCache->getKVEngine()->getAllDurableTimestamp().asULL(); // The newTimestamp may actually go backward during secondary batch application, // where we commit data file changes separately from oplog changes, so ignore @@ -273,22 +273,4 @@ void WiredTigerOplogManager::_setOplogReadTimestamp(WithLock, uint64_t newTimest "newOplogReadTimestamp"_attr = Timestamp(newTimestamp)); } -uint64_t WiredTigerOplogManager::fetchAllDurableValue(WT_CONNECTION* conn) { - // Fetch the latest all_durable value from the storage engine. This value will be a timestamp - // that has no holes (uncommitted transactions with lower timestamps) behind it. - char buf[(2 * 8 /*bytes in hex*/) + 1 /*nul terminator*/]; - auto wtstatus = conn->query_timestamp(conn, buf, "get=all_durable"); - if (wtstatus == WT_NOTFOUND) { - // Treat this as lowest possible timestamp; we need to see all preexisting data but no new - // (timestamped) data. - return StorageEngine::kMinimumTimestamp; - } else { - invariantWTOK(wtstatus); - } - - uint64_t tmp; - fassert(38002, NumberParser().base(16)(buf, &tmp)); - return tmp; -} - } // namespace mongo diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h index 011876efd3e..10f6c80f343 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h @@ -98,16 +98,6 @@ public: std::uint64_t getOplogReadTimestamp() const; void setOplogReadTimestamp(Timestamp ts); - /** - * Returns the all_durable timestamp. All transactions with timestamps earlier than the - * all_durable timestamp are committed. - * - * The all_durable timestamp is the in-memory no holes point. That does not mean that there are - * no holes behind it on disk. The all_durable timestamp also might not correspond with any - * oplog entry, but instead have a timestamp value between that of two oplog entries. - */ - uint64_t fetchAllDurableValue(WT_CONNECTION* conn); - private: /** * Runs the oplog visibility updates when signaled by triggerOplogVisibilityUpdate() until diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 685bb979a60..b58ae6c4fae 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -559,7 +559,7 @@ Timestamp WiredTigerRecoveryUnit::_beginTransactionAtAllDurableTimestamp(WT_SESS _prepareConflictBehavior, _roundUpPreparedTimestamps, RoundUpReadTimestamp::kRound); - Timestamp txnTimestamp = Timestamp(_oplogManager->fetchAllDurableValue(session->connection)); + Timestamp txnTimestamp = _sessionCache->getKVEngine()->getAllDurableTimestamp(); auto status = txnOpen.setReadSnapshot(txnTimestamp); fassert(50948, status); |