diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-07-26 12:25:26 -0400 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-07-26 12:34:32 -0400 |
commit | 25d5f6a0b01f261e633587013e4ab8116ea2930a (patch) | |
tree | b9659a708b228b7027a859ef8ed7b89b7b4f73b9 /src/mongo/db/storage | |
parent | 5f7471631d238fb3269fa0f2c3689ac62e93b61f (diff) | |
download | mongo-25d5f6a0b01f261e633587013e4ab8116ea2930a.tar.gz |
SERVER-41861 Replace 'all_committed' with 'all_durable'
Diffstat (limited to 'src/mongo/db/storage')
17 files changed, 70 insertions, 66 deletions
diff --git a/src/mongo/db/storage/biggie/biggie_kv_engine.h b/src/mongo/db/storage/biggie/biggie_kv_engine.h index fcb76c638d1..97c836b523a 100644 --- a/src/mongo/db/storage/biggie/biggie_kv_engine.h +++ b/src/mongo/db/storage/biggie/biggie_kv_engine.h @@ -135,7 +135,7 @@ public: void setJournalListener(mongo::JournalListener* jl) final {} - virtual Timestamp getAllCommittedTimestamp() const override { + virtual Timestamp getAllDurableTimestamp() const override { RecordId id = _visibilityManager->getAllCommittedRecord(); return Timestamp(id.repr()); } diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.h b/src/mongo/db/storage/devnull/devnull_kv_engine.h index 5f52ed44b7d..d0645b897b2 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.h +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.h @@ -121,7 +121,7 @@ public: void setJournalListener(JournalListener* jl) final {} - virtual Timestamp getAllCommittedTimestamp() const override { + virtual Timestamp getAllDurableTimestamp() const override { return Timestamp(); } diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h index 3eabcae6654..3a76d268efb 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h @@ -112,7 +112,7 @@ public: _journalListener = jl; } - virtual Timestamp getAllCommittedTimestamp() const override { + virtual Timestamp getAllDurableTimestamp() const override { MONGO_UNREACHABLE; } diff --git a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp index 7356d68e685..f58c2abb0b4 100644 --- a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp +++ b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp @@ -117,7 +117,7 @@ public: } void cleanShutdown() override {} void setJournalListener(JournalListener* jl) override {} - Timestamp getAllCommittedTimestamp() const override { + Timestamp getAllDurableTimestamp() const override { return {}; } Timestamp getOldestOpenReadTimestamp() const override { diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h index 0503c6f5e6f..d8b5772cd3b 100644 --- a/src/mongo/db/storage/kv/kv_engine.h +++ b/src/mongo/db/storage/kv/kv_engine.h @@ -373,9 +373,9 @@ public: } /** - * See `StorageEngine::getAllCommittedTimestamp` + * See `StorageEngine::getAllDurableTimestamp` */ - virtual Timestamp getAllCommittedTimestamp() const = 0; + virtual Timestamp getAllDurableTimestamp() const = 0; /** * See `StorageEngine::getOldestOpenReadTimestamp` diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp index e39bae73f0c..17ad60721d7 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp +++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp @@ -229,7 +229,7 @@ TEST(KVEngineTestHarness, TemporaryRecordStoreSimple) { } } -TEST(KVEngineTestHarness, AllCommittedTimestamp) { +TEST(KVEngineTestHarness, AllDurableTimestamp) { std::unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create()); KVEngine* engine = helper->getEngine(); if (!engine->supportsDocLocking()) @@ -258,17 +258,17 @@ TEST(KVEngineTestHarness, AllCommittedTimestamp) { auto t12Doc = BSON("ts" << t12); auto t21Doc = BSON("ts" << t21); - Timestamp allCommitted = engine->getAllCommittedTimestamp(); + Timestamp allDurable = engine->getAllDurableTimestamp(); MyOperationContext opCtx1(engine); WriteUnitOfWork uow1(&opCtx1); ASSERT_EQ(invariant(rs->insertRecord( &opCtx1, t11Doc.objdata(), t11Doc.objsize(), Timestamp::min())), RecordId(1, 1)); - Timestamp lastAllCommitted = allCommitted; - allCommitted = engine->getAllCommittedTimestamp(); - ASSERT_GTE(allCommitted, lastAllCommitted); - ASSERT_LT(allCommitted, t11); + Timestamp lastAllDurable = allDurable; + allDurable = engine->getAllDurableTimestamp(); + ASSERT_GTE(allDurable, lastAllDurable); + ASSERT_LT(allDurable, t11); MyOperationContext opCtx2(engine); WriteUnitOfWork uow2(&opCtx2); @@ -277,26 +277,26 @@ TEST(KVEngineTestHarness, AllCommittedTimestamp) { RecordId(2, 1)); uow2.commit(); - lastAllCommitted = allCommitted; - allCommitted = engine->getAllCommittedTimestamp(); - ASSERT_GTE(allCommitted, lastAllCommitted); - ASSERT_LT(allCommitted, t11); + lastAllDurable = allDurable; + allDurable = engine->getAllDurableTimestamp(); + ASSERT_GTE(allDurable, lastAllDurable); + ASSERT_LT(allDurable, t11); ASSERT_EQ(invariant(rs->insertRecord( &opCtx1, t12Doc.objdata(), t12Doc.objsize(), Timestamp::min())), RecordId(1, 2)); - lastAllCommitted = allCommitted; - allCommitted = engine->getAllCommittedTimestamp(); - ASSERT_GTE(allCommitted, lastAllCommitted); - ASSERT_LT(allCommitted, t11); + lastAllDurable = allDurable; + allDurable = engine->getAllDurableTimestamp(); + ASSERT_GTE(allDurable, lastAllDurable); + ASSERT_LT(allDurable, t11); uow1.commit(); - lastAllCommitted = allCommitted; - allCommitted = engine->getAllCommittedTimestamp(); - ASSERT_GTE(allCommitted, lastAllCommitted); - ASSERT_LTE(allCommitted, t21); + lastAllDurable = allDurable; + allDurable = engine->getAllDurableTimestamp(); + ASSERT_GTE(allDurable, lastAllDurable); + ASSERT_LTE(allDurable, t21); } } diff --git a/src/mongo/db/storage/mobile/mobile_kv_engine.h b/src/mongo/db/storage/mobile/mobile_kv_engine.h index a09d4187200..3762ccf0878 100644 --- a/src/mongo/db/storage/mobile/mobile_kv_engine.h +++ b/src/mongo/db/storage/mobile/mobile_kv_engine.h @@ -128,7 +128,7 @@ public: _journalListener = jl; } - virtual Timestamp getAllCommittedTimestamp() const override { + virtual Timestamp getAllDurableTimestamp() const override { MONGO_UNREACHABLE; } diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h index dcc8a37482f..1aea3e085ef 100644 --- a/src/mongo/db/storage/recovery_unit.h +++ b/src/mongo/db/storage/recovery_unit.h @@ -242,8 +242,8 @@ public: * a point in time. Any point in time returned will reflect one of the following: * - when using ReadSource::kProvided, the timestamp provided. * - when using ReadSource::kNoOverlap, the timestamp chosen by the storage engine. - * - when using ReadSource::kAllCommittedSnapshot, the timestamp chosen using the storage - * engine's all-committed timestamp. + * - when using ReadSource::kAllDurableSnapshot, the timestamp chosen using the storage + * engine's all_durable timestamp. * - when using ReadSource::kLastApplied, the timestamp chosen using the storage engine's last * applied timestamp. Can return boost::none if no timestamp has been established. * - when using ReadSource::kMajorityCommitted, the majority committed timestamp chosen by the @@ -370,10 +370,10 @@ public: */ kLastApplied, /** - * Read from the all-committed timestamp. New transactions will always read from the same + * Read from the all_durable timestamp. New transactions will always read from the same * timestamp and never advance. */ - kAllCommittedSnapshot, + kAllDurableSnapshot, /** * Read from the timestamp provided to setTimestampReadSource. */ diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index 7722aaaa956..1b0bf3e6216 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -500,12 +500,16 @@ public: }; /** - * Returns the all committed timestamp. All transactions with timestamps earlier than the - * all committed timestamp are committed. Only storage engines that support document level - * locking must provide an implementation. Other storage engines may provide a no-op - * implementation. + * Returns the all_durable timestamp. All transactions with timestamps earlier than the + * 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 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 + * that were prepared but not committed which could make the stable timestamp briefly jump back. */ - virtual Timestamp getAllCommittedTimestamp() const = 0; + virtual Timestamp getAllDurableTimestamp() const = 0; /** * Returns the oldest read timestamp in use by an open transaction. Storage engines that support diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp index f9498194fc4..57dcb407253 100644 --- a/src/mongo/db/storage/storage_engine_impl.cpp +++ b/src/mongo/db/storage/storage_engine_impl.cpp @@ -805,8 +805,8 @@ void StorageEngineImpl::replicationBatchIsComplete() const { return _engine->replicationBatchIsComplete(); } -Timestamp StorageEngineImpl::getAllCommittedTimestamp() const { - return _engine->getAllCommittedTimestamp(); +Timestamp StorageEngineImpl::getAllDurableTimestamp() const { + return _engine->getAllDurableTimestamp(); } Timestamp StorageEngineImpl::getOldestOpenReadTimestamp() const { diff --git a/src/mongo/db/storage/storage_engine_impl.h b/src/mongo/db/storage/storage_engine_impl.h index db471036501..54182dd4676 100644 --- a/src/mongo/db/storage/storage_engine_impl.h +++ b/src/mongo/db/storage/storage_engine_impl.h @@ -139,7 +139,7 @@ public: virtual boost::optional<Timestamp> getLastStableRecoveryTimestamp() const override; - virtual Timestamp getAllCommittedTimestamp() const override; + virtual Timestamp getAllDurableTimestamp() const override; virtual Timestamp getOldestOpenReadTimestamp() const override; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 422f838ba5f..026e7d59c74 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -1761,8 +1761,8 @@ StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp(OperationCont return {stableTimestamp}; } -Timestamp WiredTigerKVEngine::getAllCommittedTimestamp() const { - return Timestamp(_oplogManager->fetchAllCommittedValue(_conn)); +Timestamp WiredTigerKVEngine::getAllDurableTimestamp() const { + return Timestamp(_oplogManager->fetchAllDurableValue(_conn)); } Timestamp WiredTigerKVEngine::getOldestOpenReadTimestamp() const { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 625cb5a565a..c1502094ec5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -230,7 +230,7 @@ public: */ boost::optional<Timestamp> getLastStableRecoveryTimestamp() const override; - Timestamp getAllCommittedTimestamp() const override; + Timestamp getAllDurableTimestamp() const override; Timestamp getOldestOpenReadTimestamp() const override; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp index 28dd48f261f..e3ec7e9097d 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp @@ -207,7 +207,7 @@ void WiredTigerOplogManager::_oplogJournalThreadLoop(WiredTigerSessionCache* ses _opsWaitingForJournal = false; lk.unlock(); - const uint64_t newTimestamp = fetchAllCommittedValue(sessionCache->conn()); + const uint64_t newTimestamp = fetchAllDurableValue(sessionCache->conn()); // The newTimestamp may actually go backward during secondary batch application, // where we commit data file changes separately from oplog changes, so ignore @@ -249,11 +249,11 @@ void WiredTigerOplogManager::_setOplogReadTimestamp(WithLock, uint64_t newTimest LOG(2) << "Setting new oplogReadTimestamp: " << Timestamp(newTimestamp); } -uint64_t WiredTigerOplogManager::fetchAllCommittedValue(WT_CONNECTION* conn) { - // Fetch the latest all_committed value from the storage engine. This value will be a - // timestamp that has no holes (uncommitted transactions with lower timestamps) behind it. +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_committed"); + 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. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h index f71ba7e5214..9a82985fc28 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h @@ -41,7 +41,7 @@ class WiredTigerRecordStore; class WiredTigerSessionCache; -// Manages oplog visibility, by periodically querying WiredTiger's all_committed timestamp value and +// Manages oplog visibility, by periodically querying WiredTiger's all_durable timestamp value and // then using that timestamp for all transactions that read the oplog collection. class WiredTigerOplogManager { WiredTigerOplogManager(const WiredTigerOplogManager&) = delete; @@ -78,9 +78,9 @@ public: void waitForAllEarlierOplogWritesToBeVisible(const WiredTigerRecordStore* oplogRecordStore, OperationContext* opCtx); - // Returns the all committed timestamp. All transactions with timestamps earlier than the - // all committed timestamp are committed. - uint64_t fetchAllCommittedValue(WT_CONNECTION* conn); + // Returns the all_durable timestamp. All transactions with timestamps earlier than the + // all_durable timestamp are committed. + uint64_t fetchAllDurableValue(WT_CONNECTION* conn); private: void _oplogJournalThreadLoop(WiredTigerSessionCache* sessionCache, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 3f26c7b8614..33f1548411c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -425,7 +425,7 @@ boost::optional<Timestamp> WiredTigerRecoveryUnit::getPointInTimeReadTimestamp() // opened. case ReadSource::kNoOverlap: case ReadSource::kLastApplied: - case ReadSource::kAllCommittedSnapshot: + case ReadSource::kAllDurableSnapshot: break; } @@ -441,7 +441,7 @@ boost::optional<Timestamp> WiredTigerRecoveryUnit::getPointInTimeReadTimestamp() } return boost::none; case ReadSource::kNoOverlap: - case ReadSource::kAllCommittedSnapshot: + case ReadSource::kAllDurableSnapshot: invariant(!_readAtTimestamp.isNull()); return _readAtTimestamp; @@ -501,9 +501,9 @@ void WiredTigerRecoveryUnit::_txnOpen() { _readAtTimestamp = _beginTransactionAtNoOverlapTimestamp(session); break; } - case ReadSource::kAllCommittedSnapshot: { + case ReadSource::kAllDurableSnapshot: { if (_readAtTimestamp.isNull()) { - _readAtTimestamp = _beginTransactionAtAllCommittedTimestamp(session); + _readAtTimestamp = _beginTransactionAtAllDurableTimestamp(session); break; } // Intentionally continue to the next case to read at the _readAtTimestamp. @@ -527,17 +527,17 @@ void WiredTigerRecoveryUnit::_txnOpen() { LOG(3) << "WT begin_transaction for snapshot id " << _mySnapshotId; } -Timestamp WiredTigerRecoveryUnit::_beginTransactionAtAllCommittedTimestamp(WT_SESSION* session) { +Timestamp WiredTigerRecoveryUnit::_beginTransactionAtAllDurableTimestamp(WT_SESSION* session) { WiredTigerBeginTxnBlock txnOpen(session, _prepareConflictBehavior, _roundUpPreparedTimestamps, RoundUpReadTimestamp::kRound); - Timestamp txnTimestamp = Timestamp(_oplogManager->fetchAllCommittedValue(session->connection)); + Timestamp txnTimestamp = Timestamp(_oplogManager->fetchAllDurableValue(session->connection)); auto status = txnOpen.setReadSnapshot(txnTimestamp); fassert(50948, status); // Since this is not in a critical section, we might have rounded to oldest between - // calling getAllCommitted and setReadSnapshot. We need to get the actual read timestamp we + // calling getAllDurable and setReadSnapshot. We need to get the actual read timestamp we // used. auto readTimestamp = _getTransactionReadTimestamp(session); txnOpen.done(); @@ -547,7 +547,7 @@ Timestamp WiredTigerRecoveryUnit::_beginTransactionAtAllCommittedTimestamp(WT_SE Timestamp WiredTigerRecoveryUnit::_beginTransactionAtNoOverlapTimestamp(WT_SESSION* session) { auto lastApplied = _sessionCache->snapshotManager().getLocalSnapshot(); - Timestamp allCommitted = Timestamp(_oplogManager->fetchAllCommittedValue(session->connection)); + Timestamp allDurable = Timestamp(_oplogManager->fetchAllDurableValue(session->connection)); // When using timestamps for reads and writes, it's important that readers and writers don't // overlap with the timestamps they use. In other words, at any point in the system there should @@ -555,13 +555,13 @@ Timestamp WiredTigerRecoveryUnit::_beginTransactionAtNoOverlapTimestamp(WT_SESSI // at, or earlier than T. This time T is called the no-overlap point. Using the `kNoOverlap` // ReadSource will compute the most recent known time that is safe to read at. - // The no-overlap point is computed as the minimum of the storage engine's all-committed time + // The no-overlap point is computed as the minimum of the storage engine's all_durable time // and replication's last applied time. On primaries, the last applied time is updated as // transactions commit, which is not necessarily in the order they appear in the oplog. Thus - // the all-committed time is an appropriate value to read at. + // the all_durable time is an appropriate value to read at. - // On secondaries, however, the all-committed time, as computed by the storage engine, can - // advance before oplog application completes a batch. This is because the all-committed time + // On secondaries, however, the all_durable time, as computed by the storage engine, can + // advance before oplog application completes a batch. This is because the all_durable time // is only computed correctly if the storage engine is informed of commit timestamps in // increasing order. Because oplog application processes a batch of oplog entries out of order, // the timestamping requirement is not satisfied. Secondaries, however, only update the last @@ -569,11 +569,11 @@ Timestamp WiredTigerRecoveryUnit::_beginTransactionAtNoOverlapTimestamp(WT_SESSI // secondaries. // By taking the minimum of the two values, storage can compute a legal time to read at without - // knowledge of the replication state. The no-overlap point is the minimum of the all-committed + // knowledge of the replication state. The no-overlap point is the minimum of the all_durable // time, which represents the point where no transactions will commit any earlier, and // lastApplied, which represents the highest optime a node has applied, a point no readers // should read afterward. - Timestamp readTimestamp = (lastApplied) ? std::min(*lastApplied, allCommitted) : allCommitted; + Timestamp readTimestamp = (lastApplied) ? std::min(*lastApplied, allDurable) : allDurable; WiredTigerBeginTxnBlock txnOpen(session, _prepareConflictBehavior, @@ -582,7 +582,7 @@ Timestamp WiredTigerRecoveryUnit::_beginTransactionAtNoOverlapTimestamp(WT_SESSI auto status = txnOpen.setReadSnapshot(readTimestamp); fassert(51066, status); - // We might have rounded to oldest between calling getAllCommitted and setReadSnapshot. We need + // We might have rounded to oldest between calling getAllDurable and setReadSnapshot. We need // to get the actual read timestamp we used. readTimestamp = _getTransactionReadTimestamp(session); txnOpen.done(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h index 7ed61acf29b..81483c51cd7 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h @@ -208,10 +208,10 @@ private: void _txnOpen(); /** - * Starts a transaction at the current all-committed timestamp. + * Starts a transaction at the current all_durable timestamp. * Returns the timestamp the transaction was started at. */ - Timestamp _beginTransactionAtAllCommittedTimestamp(WT_SESSION* session); + Timestamp _beginTransactionAtAllDurableTimestamp(WT_SESSION* session); /** * Starts a transaction at the no-overlap timestamp. Returns the timestamp the transaction |