diff options
author | Louis Williams <louis.williams@mongodb.com> | 2020-04-23 14:39:13 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-23 18:51:40 +0000 |
commit | 66783cb504c25061b00c03fe55b70e3ca4125ed5 (patch) | |
tree | fa1e68c3f147d42134f5e54e50d6d0a33a323afe /src/mongo/db/index | |
parent | 7cde21f53367705a06e7580d63648938ea688a1d (diff) | |
download | mongo-66783cb504c25061b00c03fe55b70e3ca4125ed5.tar.gz |
SERVER-47605 Single-phase index builds should only check constraint violations upon completion
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_build_interceptor.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/index/index_build_interceptor.h | 16 |
2 files changed, 8 insertions, 26 deletions
diff --git a/src/mongo/db/index/index_build_interceptor.cpp b/src/mongo/db/index/index_build_interceptor.cpp index a5350dc5701..972ae9e2927 100644 --- a/src/mongo/db/index/index_build_interceptor.cpp +++ b/src/mongo/db/index/index_build_interceptor.cpp @@ -67,18 +67,13 @@ bool IndexBuildInterceptor::typeCanFastpathMultikeyUpdates(IndexType indexType) return (indexType == INDEX_BTREE); } -IndexBuildInterceptor::IndexBuildInterceptor(OperationContext* opCtx, - IndexCatalogEntry* entry, - TrackSkippedRecords trackSkippedRecords) +IndexBuildInterceptor::IndexBuildInterceptor(OperationContext* opCtx, IndexCatalogEntry* entry) : _indexCatalogEntry(entry), _sideWritesTable( opCtx->getServiceContext()->getStorageEngine()->makeTemporaryRecordStore(opCtx)), + _skippedRecordTracker(entry), _sideWritesCounter(std::make_shared<AtomicWord<long long>>()) { - if (TrackSkippedRecords::kTrack == trackSkippedRecords) { - _skippedRecordTracker = std::make_unique<SkippedRecordTracker>(_indexCatalogEntry); - } - if (entry->descriptor()->unique()) { _duplicateKeyTracker = std::make_unique<DuplicateKeyTracker>(opCtx, entry); } @@ -98,9 +93,7 @@ void IndexBuildInterceptor::deleteTemporaryTables(OperationContext* opCtx) { if (_duplicateKeyTracker) { _duplicateKeyTracker->deleteTemporaryTable(opCtx); } - if (_skippedRecordTracker) { - _skippedRecordTracker->deleteTemporaryTable(opCtx); - } + _skippedRecordTracker.deleteTemporaryTable(opCtx); } Status IndexBuildInterceptor::recordDuplicateKeys(OperationContext* opCtx, @@ -487,10 +480,7 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx, Status IndexBuildInterceptor::retrySkippedRecords(OperationContext* opCtx, const Collection* collection) { - if (!_skippedRecordTracker) { - return Status::OK(); - } - return _skippedRecordTracker->retrySkippedRecords(opCtx, collection); + return _skippedRecordTracker.retrySkippedRecords(opCtx, collection); } diff --git a/src/mongo/db/index/index_build_interceptor.h b/src/mongo/db/index/index_build_interceptor.h index 4afb108d15b..8458dc0620d 100644 --- a/src/mongo/db/index/index_build_interceptor.h +++ b/src/mongo/db/index/index_build_interceptor.h @@ -55,12 +55,6 @@ public: enum class Op { kInsert, kDelete }; /** - * Indicates whether this interceptor will allow tracking of documents skipped due to key - * generation errors. When 'kTrack', a SkippedRecordTracker is created. - */ - enum class TrackSkippedRecords { kNoTrack, kTrack }; - - /** * Indicates whether to record duplicate keys that have been inserted into the index. When set * to 'kNoTrack', inserted duplicate keys will be ignored. When set to 'kTrack', a subsequent * call to checkDuplicateKeyConstraints is required. @@ -76,9 +70,7 @@ public: * * deleteTemporaryTable() must be called before destruction to delete the temporary tables. */ - IndexBuildInterceptor(OperationContext* opCtx, - IndexCatalogEntry* entry, - TrackSkippedRecords trackSkippedRecords); + IndexBuildInterceptor(OperationContext* opCtx, IndexCatalogEntry* entry); /** * Deletes the temporary side writes and duplicate key constraint violations tables. Must be @@ -138,11 +130,11 @@ public: DrainYieldPolicy drainYieldPolicy); SkippedRecordTracker* getSkippedRecordTracker() { - return _skippedRecordTracker.get(); + return &_skippedRecordTracker; } const SkippedRecordTracker* getSkippedRecordTracker() const { - return _skippedRecordTracker.get(); + return &_skippedRecordTracker; } /** @@ -187,7 +179,7 @@ private: std::unique_ptr<TemporaryRecordStore> _sideWritesTable; // Records RecordIds that have been skipped due to indexing errors. - std::unique_ptr<SkippedRecordTracker> _skippedRecordTracker; + SkippedRecordTracker _skippedRecordTracker; std::unique_ptr<DuplicateKeyTracker> _duplicateKeyTracker; |