From 8664909531ba0f604f9e7da16c0f14bc144a4dd4 Mon Sep 17 00:00:00 2001 From: Yuhong Zhang Date: Tue, 30 Aug 2022 15:06:28 +0000 Subject: SERVER-69186 Track newly created indexes for background validation again --- .../db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 6 ++++- .../db/storage/wiredtiger/wiredtiger_kv_engine.h | 28 ++++++++++++++++++++++ .../wiredtiger/wiredtiger_session_cache.cpp | 6 ++++- 3 files changed, 38 insertions(+), 2 deletions(-) (limited to 'src/mongo/db/storage/wiredtiger') diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index ad6abdca8a2..65c422d2226 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -2013,6 +2013,7 @@ void WiredTigerKVEngine::_checkpoint(WT_SESSION* session) { // Third, stableTimestamp >= initialDataTimestamp: Take stable checkpoint. Steady state // case. if (initialDataTimestamp.asULL() <= 1) { + clearIndividuallyCheckpointedIndexes(); invariantWTOK(session->checkpoint(session, "use_timestamp=false"), session); LOGV2_FOR_RECOVERY(5576602, 2, @@ -2034,7 +2035,10 @@ void WiredTigerKVEngine::_checkpoint(WT_SESSION* session) { "stableTimestamp"_attr = stableTimestamp, "oplogNeededForRollback"_attr = toString(oplogNeededForRollback)); - invariantWTOK(session->checkpoint(session, "use_timestamp=true"), session); + { + clearIndividuallyCheckpointedIndexes(); + invariantWTOK(session->checkpoint(session, "use_timestamp=true"), session); + } if (oplogNeededForRollback.isOK()) { // Now that the checkpoint is durable, publish the oplog needed to recover from it. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 748ec6c4c1d..10672661629 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -119,6 +119,13 @@ public: bool supportsDirectoryPerDB() const override; + /** + * WiredTiger supports checkpoints when it isn't running in memory. + */ + bool supportsCheckpoints() const override { + return !isEphemeral(); + } + void checkpoint() override; bool isEphemeral() const override { @@ -371,6 +378,18 @@ public: return _clockSource; } + void addIndividuallyCheckpointedIndex(const std::string& ident) override { + _checkpointedIndexes.insert(ident); + } + + void clearIndividuallyCheckpointedIndexes() override { + _checkpointedIndexes.clear(); + } + + bool isInIndividuallyCheckpointedIndexes(const std::string& ident) const override { + return _checkpointedIndexes.find(ident) != _checkpointedIndexes.end(); + } + StatusWith pinOldestTimestamp(OperationContext* opCtx, const std::string& requestingServiceName, Timestamp requestedTimestamp, @@ -514,6 +533,15 @@ private: // timestamp. Provided by replication layer because WT does not persist timestamps. AtomicWord _initialDataTimestamp; + // Required for taking a checkpoint; and can be used to ensure multiple checkpoint cursors + // target the same checkpoint. + Lock::ResourceMutex _checkpointCursorMutex = Lock::ResourceMutex("checkpointCursorMutex"); + + // A set of indexes that were individually checkpoint'ed and are not consistent with the rest + // of the checkpoint's PIT view of the storage data. This set is reset when a storage-wide WT + // checkpoint is taken that makes the PIT view consistent again. + std::set _checkpointedIndexes; + AtomicWord _oplogNeededForCrashRecovery; std::unique_ptr _runTimeConfigParam; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index a1ad92795a8..a79e5494cdc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -310,7 +310,10 @@ void WiredTigerSessionCache::waitUntilDurable(OperationContext* opCtx, auto config = syncType == Fsync::kCheckpointStableTimestamp ? "use_timestamp=true" : "use_timestamp=false"; - invariantWTOK(s->checkpoint(s, config), s); + { + _engine->clearIndividuallyCheckpointedIndexes(); + invariantWTOK(s->checkpoint(s, config), s); + } if (token) { journalListener->onDurable(token.value()); @@ -362,6 +365,7 @@ void WiredTigerSessionCache::waitUntilDurable(OperationContext* opCtx, _waitUntilDurableSession); LOGV2_DEBUG(22419, 4, "flushed journal"); } else { + _engine->clearIndividuallyCheckpointedIndexes(); invariantWTOK(_waitUntilDurableSession->checkpoint(_waitUntilDurableSession, nullptr), _waitUntilDurableSession); LOGV2_DEBUG(22420, 4, "created checkpoint"); -- cgit v1.2.1