diff options
author | Yuhong Zhang <yuhong.zhang@mongodb.com> | 2022-08-30 15:06:28 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-30 16:12:41 +0000 |
commit | 8664909531ba0f604f9e7da16c0f14bc144a4dd4 (patch) | |
tree | c6fa67ce4671acd5fa68098f4b518f74f4ba11e0 /src/mongo/db/storage/wiredtiger | |
parent | 875211fdaeeae66170bab08b1e5090bb77120686 (diff) | |
download | mongo-8664909531ba0f604f9e7da16c0f14bc144a4dd4.tar.gz |
SERVER-69186 Track newly created indexes for background validation again
Diffstat (limited to 'src/mongo/db/storage/wiredtiger')
3 files changed, 38 insertions, 2 deletions
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<Timestamp> 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<std::uint64_t> _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<std::string> _checkpointedIndexes; + AtomicWord<std::uint64_t> _oplogNeededForCrashRecovery; std::unique_ptr<WiredTigerEngineRuntimeConfigParameter> _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"); |