diff options
author | Louis Williams <louis.williams@mongodb.com> | 2019-01-25 17:09:09 -0500 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2019-01-31 18:25:19 -0500 |
commit | f4656acfee11569a796e06d14e4825ab54d39ecc (patch) | |
tree | 6e0c71fe0e1f4fd32f95e6d7dc8f3b1e3b17b569 /src/mongo/db/catalog/index_build_block.cpp | |
parent | 79142496a53ae70d875a8797defbb4cdd699ce4f (diff) | |
download | mongo-f4656acfee11569a796e06d14e4825ab54d39ecc.tar.gz |
SERVER-37645 Add parsing for new index build fields in catalog
Diffstat (limited to 'src/mongo/db/catalog/index_build_block.cpp')
-rw-r--r-- | src/mongo/db/catalog/index_build_block.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/index_build_block.cpp b/src/mongo/db/catalog/index_build_block.cpp index 51294456a36..22f60db88d3 100644 --- a/src/mongo/db/catalog/index_build_block.cpp +++ b/src/mongo/db/catalog/index_build_block.cpp @@ -83,12 +83,12 @@ Status IndexCatalogImpl::IndexBuildBlock::init() { } // Setup on-disk structures. + const auto protocol = IndexBuildProtocol::kTwoPhase; Status status = _collection->getCatalogEntry()->prepareForIndexBuild( - _opCtx, descriptor.get(), isBackgroundSecondaryBuild); + _opCtx, descriptor.get(), protocol, isBackgroundSecondaryBuild); if (!status.isOK()) return status; - auto* const descriptorPtr = descriptor.get(); const bool initFromDisk = false; const bool isReadyIndex = false; _entry = _catalog->_setupInMemoryStructures( @@ -98,6 +98,20 @@ Status IndexCatalogImpl::IndexBuildBlock::init() { _indexBuildInterceptor = stdx::make_unique<IndexBuildInterceptor>(_opCtx, _entry); _entry->setIndexBuildInterceptor(_indexBuildInterceptor.get()); + const auto sideWritesIdent = _indexBuildInterceptor->getSideWritesTableIdent(); + // Only unique indexes have a constraint violations table. + const auto constraintsIdent = (_entry->descriptor()->unique()) + ? boost::optional<std::string>( + _indexBuildInterceptor->getConstraintViolationsTableIdent()) + : boost::none; + + if (IndexBuildProtocol::kTwoPhase == protocol) { + _collection->getCatalogEntry()->setIndexBuildScanning( + _opCtx, _entry->descriptor()->indexName(), sideWritesIdent, constraintsIdent); + } + } + + if (isBackgroundIndex) { _opCtx->recoveryUnit()->onCommit( [ opCtx = _opCtx, entry = _entry, collection = _collection ]( boost::optional<Timestamp> commitTime) { @@ -112,7 +126,7 @@ Status IndexCatalogImpl::IndexBuildBlock::init() { // Register this index with the CollectionInfoCache to regenerate the cache. This way, updates // occurring while an index is being build in the background will be aware of whether or not // they need to modify any indexes. - _collection->infoCache()->addedIndex(_opCtx, descriptorPtr); + _collection->infoCache()->addedIndex(_opCtx, _entry->descriptor()); return Status::OK(); } |