diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2020-09-08 12:41:03 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-10 22:22:32 +0000 |
commit | b68df4e87d60fcaeb5cb5ea34762695910c8f2c6 (patch) | |
tree | d97eb139ec44b4e20e803d324fbc33c6e71d6872 /src/mongo/db/storage/storage_engine_impl.cpp | |
parent | 4ff797fa438d9d1eb49ae9335174fb1140fc86eb (diff) | |
download | mongo-b68df4e87d60fcaeb5cb5ea34762695910c8f2c6.tar.gz |
SERVER-49215 Differentiate internal idents used for resumable index build information from other internal idents
Diffstat (limited to 'src/mongo/db/storage/storage_engine_impl.cpp')
-rw-r--r-- | src/mongo/db/storage/storage_engine_impl.cpp | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp index 88c183919e1..e8efa8ce88d 100644 --- a/src/mongo/db/storage/storage_engine_impl.cpp +++ b/src/mongo/db/storage/storage_engine_impl.cpp @@ -326,7 +326,7 @@ Status StorageEngineImpl::_recoverOrphanedCollection(OperationContext* opCtx, return Status::OK(); } -bool StorageEngineImpl::_handleInternalIdents( +bool StorageEngineImpl::_handleInternalIdent( OperationContext* opCtx, const std::string& ident, InternalIdentReconcilePolicy internalIdentReconcilePolicy, @@ -345,14 +345,15 @@ bool StorageEngineImpl::_handleInternalIdents( return true; } + if (!_catalog->isResumableIndexBuildIdent(ident)) { + return false; + } + // When starting up after a clean shutdown and resumable index builds are supported, find the // internal idents that contain the relevant information to resume each index build and recover // the state. auto rs = _engine->getRecordStore(opCtx, "", ident, CollectionOptions()); - // Look at the contents to determine whether this ident will contain information for - // resuming an index build. - // TODO SERVER-49215: differentiate the internal idents without looking at the contents. auto cursor = rs->getCursor(opCtx); auto record = cursor->next(); if (record) { @@ -360,36 +361,35 @@ bool StorageEngineImpl::_handleInternalIdents( // Parse the documents here so that we can restart the build if the document doesn't // contain all the necessary information to be able to resume building the index. - if (doc.hasField("phase")) { - ResumeIndexInfo resumeInfo; - try { - if (MONGO_unlikely(failToParseResumeIndexInfo.shouldFail())) { - uasserted(ErrorCodes::FailPointEnabled, - "failToParseResumeIndexInfo fail point is enabled"); - } - - resumeInfo = ResumeIndexInfo::parse(IDLParserErrorContext("ResumeIndexInfo"), doc); - } catch (const DBException& e) { - LOGV2(4916300, "Failed to parse resumable index info", "error"_attr = e.toStatus()); - - // Ignore the error so that we can restart the index build instead of resume it. We - // should drop the internal ident if we failed to parse. - internalIdentsToDrop->insert(ident); - return true; + ResumeIndexInfo resumeInfo; + try { + if (MONGO_unlikely(failToParseResumeIndexInfo.shouldFail())) { + uasserted(ErrorCodes::FailPointEnabled, + "failToParseResumeIndexInfo fail point is enabled"); } - reconcileResult->indexBuildsToResume.push_back(resumeInfo); + resumeInfo = ResumeIndexInfo::parse(IDLParserErrorContext("ResumeIndexInfo"), doc); + } catch (const DBException& e) { + LOGV2(4916300, "Failed to parse resumable index info", "error"_attr = e.toStatus()); - // Once we have parsed the resume info, we can safely drop the internal ident. + // Ignore the error so that we can restart the index build instead of resume it. We + // should drop the internal ident if we failed to parse. internalIdentsToDrop->insert(ident); - - LOGV2(4916301, - "Found unfinished index build to resume", - "buildUUID"_attr = resumeInfo.getBuildUUID(), - "collectionUUID"_attr = resumeInfo.getCollectionUUID(), - "phase"_attr = IndexBuildPhase_serializer(resumeInfo.getPhase())); return true; } + + reconcileResult->indexBuildsToResume.push_back(resumeInfo); + + // Once we have parsed the resume info, we can safely drop the internal ident. + internalIdentsToDrop->insert(ident); + + LOGV2(4916301, + "Found unfinished index build to resume", + "buildUUID"_attr = resumeInfo.getBuildUUID(), + "collectionUUID"_attr = resumeInfo.getCollectionUUID(), + "phase"_attr = IndexBuildPhase_serializer(resumeInfo.getPhase())); + + return true; } return false; @@ -448,12 +448,12 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn continue; } - if (_handleInternalIdents(opCtx, - it, - internalIdentReconcilePolicy, - &reconcileResult, - &internalIdentsToDrop, - &allInternalIdents)) { + if (_handleInternalIdent(opCtx, + it, + internalIdentReconcilePolicy, + &reconcileResult, + &internalIdentsToDrop, + &allInternalIdents)) { continue; } @@ -864,10 +864,18 @@ std::unique_ptr<TemporaryRecordStore> StorageEngineImpl::makeTemporaryRecordStor OperationContext* opCtx) { std::unique_ptr<RecordStore> rs = _engine->makeTemporaryRecordStore(opCtx, _catalog->newInternalIdent()); - LOGV2_DEBUG(22258, + LOGV2_DEBUG(22258, 1, "Created temporary record store", "ident"_attr = rs->getIdent()); + return std::make_unique<TemporaryKVRecordStore>(getEngine(), std::move(rs)); +} + +std::unique_ptr<TemporaryRecordStore> +StorageEngineImpl::makeTemporaryRecordStoreForResumableIndexBuild(OperationContext* opCtx) { + std::unique_ptr<RecordStore> rs = + _engine->makeTemporaryRecordStore(opCtx, _catalog->newInternalResumableIndexBuildIdent()); + LOGV2_DEBUG(4921500, 1, - "created temporary record store: {rs_getIdent}", - "rs_getIdent"_attr = rs->getIdent()); + "Created temporary record store for resumable index build", + "ident"_attr = rs->getIdent()); return std::make_unique<TemporaryKVRecordStore>(getEngine(), std::move(rs)); } |