diff options
author | Louis Williams <louis.williams@mongodb.com> | 2018-04-16 11:51:21 -0400 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2018-04-17 13:04:01 -0400 |
commit | 228106a7416288ad6263ab67878477cc23e9c23f (patch) | |
tree | 4ede31bc0ef7a0fa4b1961dd869a666f1b53438a | |
parent | c61fc7b0a6281cfbb7c14652cc7b097daeb4088e (diff) | |
download | mongo-228106a7416288ad6263ab67878477cc23e9c23f.tar.gz |
SERVER-34494 Background index builds on secondaries should set the collection minimumVisibleSnapshot
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index a239422105f..9a090e94109 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -409,8 +409,6 @@ Status IndexCatalogImpl::IndexBuildBlock::init() { _indexName = descriptor->indexName(); _indexNamespace = descriptor->indexNamespace(); - /// ---------- setup on disk structures ---------------- - bool isBackgroundSecondaryBuild = false; if (auto replCoord = repl::ReplicationCoordinator::get(_opCtx)) { isBackgroundSecondaryBuild = @@ -418,13 +416,22 @@ Status IndexCatalogImpl::IndexBuildBlock::init() { replCoord->getMemberState().secondary() && _spec["background"].trueValue(); } + // Setup on-disk structures. Status status = _collection->getCatalogEntry()->prepareForIndexBuild( _opCtx, descriptor.get(), isBackgroundSecondaryBuild); if (!status.isOK()) return status; + if (isBackgroundSecondaryBuild) { + _opCtx->recoveryUnit()->onCommit([&] { + auto commitTs = _opCtx->recoveryUnit()->getCommitTimestamp(); + if (!commitTs.isNull()) { + _collection->setMinimumVisibleSnapshot(commitTs); + } + }); + } + auto* const descriptorPtr = descriptor.get(); - /// ---------- setup in memory structures ---------------- const bool initFromDisk = false; _entry = IndexCatalogImpl::_setupInMemoryStructures( _catalog, _opCtx, std::move(descriptor), initFromDisk); |