diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2019-10-21 15:46:50 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-21 15:46:50 +0000 |
commit | 95584cd484eb94e8a3266e23f6594338ed878b88 (patch) | |
tree | 23bef212ece3532199694c7e385e210755fc3a04 /src/mongo/db/catalog | |
parent | ce3261545db4767f18e390c50d59c6530e948655 (diff) | |
download | mongo-95584cd484eb94e8a3266e23f6594338ed878b88.tar.gz |
SERVER-43942 track newly created indexes until they are part of a consistent WT checkpoint, and skip them in background validation
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r-- | src/mongo/db/catalog/catalog_control_test.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/catalog/multi_index_block.cpp | 24 | ||||
-rw-r--r-- | src/mongo/db/catalog/validate_state.cpp | 11 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/catalog_control_test.cpp b/src/mongo/db/catalog/catalog_control_test.cpp index 23fc51218d2..7a8a530731d 100644 --- a/src/mongo/db/catalog/catalog_control_test.cpp +++ b/src/mongo/db/catalog/catalog_control_test.cpp @@ -186,6 +186,11 @@ public: std::unique_ptr<CheckpointLock> getCheckpointLock(OperationContext* opCtx) final { return nullptr; } + void addIndividuallyCheckpointedIndexToList(const std::string& ident) final {} + void clearIndividuallyCheckpointedIndexesList() final {} + bool isInIndividuallyCheckpointedIndexesList(const std::string& ident) const final { + return false; + } }; /** diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp index f206610698b..20a97d48938 100644 --- a/src/mongo/db/catalog/multi_index_block.cpp +++ b/src/mongo/db/catalog/multi_index_block.cpp @@ -50,6 +50,7 @@ #include "mongo/db/query/collection_query_info.h" #include "mongo/db/repl/repl_set_config.h" #include "mongo/db/repl/replication_coordinator.h" +#include "mongo/db/storage/durable_catalog.h" #include "mongo/db/storage/storage_options.h" #include "mongo/db/storage/write_unit_of_work.h" #include "mongo/logger/redaction.h" @@ -819,6 +820,29 @@ Status MultiIndexBlock::commit(OperationContext* opCtx, _indexes[i].block->getEntry()->setMultikey(opCtx, *multikeyPaths); } } + + if (opCtx->getServiceContext()->getStorageEngine()->supportsCheckpoints()) { + // Add the new index ident to a list so that the validate cmd with {background:true} + // can ignore the new index until it is regularly checkpoint'ed with the rest of the + // storage data. + // + // Index builds use the bulk loader, which can provoke a checkpoint of just that index. + // This makes the checkpoint's PIT view of the collection and indexes inconsistent until + // the next storage-wide checkpoint is taken, at which point the list will be reset. + // + // Note that it is okay if the index commit fails: background validation will never try + // to look at the index and the list will be reset by the next periodic storage-wide + // checkpoint. + // + // TODO (SERVER-44012): to remove this workaround. + auto checkpointLock = + opCtx->getServiceContext()->getStorageEngine()->getCheckpointLock(opCtx); + auto indexIdent = + opCtx->getServiceContext()->getStorageEngine()->getCatalog()->getIndexIdent( + opCtx, collection->ns(), _indexes[i].block->getIndexName()); + opCtx->getServiceContext()->getStorageEngine()->addIndividuallyCheckpointedIndexToList( + indexIdent); + } } onCommit(); diff --git a/src/mongo/db/catalog/validate_state.cpp b/src/mongo/db/catalog/validate_state.cpp index 82123f96eaf..bf9aa1f6de7 100644 --- a/src/mongo/db/catalog/validate_state.cpp +++ b/src/mongo/db/catalog/validate_state.cpp @@ -234,6 +234,17 @@ void ValidateState::initializeCursors(OperationContext* opCtx) { continue; } + // Skip any newly created indexes that, because they were built with a WT bulk loader, are + // checkpoint'ed but not yet consistent with the rest of checkpoint's PIT view of the data. + if (_background && + opCtx->getServiceContext()->getStorageEngine()->isInIndividuallyCheckpointedIndexesList( + diskIndexIdent)) { + _indexCursors.erase(desc->indexName()); + log() << "Skipping validation on index '" << desc->indexName() << "' in collection '" + << _nss << "' because the index data is not yet consistent in the checkpoint."; + continue; + } + _indexes.push_back(indexCatalog->getEntryShared(desc)); } |