diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2021-11-01 20:27:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-02 00:38:24 +0000 |
commit | ca88ae9117d06b90dfaf57940484086bd4e0ed82 (patch) | |
tree | 816231bec678986843f197b5cab7b4a6139e3c64 | |
parent | f9c31646ad3281410ec757222fffdf80867e0bea (diff) | |
download | mongo-ca88ae9117d06b90dfaf57940484086bd4e0ed82.tar.gz |
SERVER-61094 Use a dedicated pooled KeyString builder per index
This avoids underlying SharedBuffer to be shared for KeyString for
separate indexes. Allows indexes that need to spill to disk to
independently free memory instead of being pinned by unrelated other
indexes.
(cherry picked from commit 5d1078c60e8f24e027dc72d7ceeac4dab49908b9)
-rw-r--r-- | src/mongo/db/catalog/index_build_block.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_build_block.h | 9 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/catalog/multi_index_block.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/catalog/validate_adaptor.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/exec/working_set_common.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 3 | ||||
-rw-r--r-- | src/mongo/db/index/skipped_record_tracker.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/query/sbe_stage_builder.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/storage/execution_context.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/storage/execution_context.h | 6 | ||||
-rw-r--r-- | src/mongo/dbtests/validate_tests.cpp | 62 |
13 files changed, 91 insertions, 60 deletions
diff --git a/src/mongo/db/catalog/index_build_block.cpp b/src/mongo/db/catalog/index_build_block.cpp index 5cd4df60e11..80a45ad0f56 100644 --- a/src/mongo/db/catalog/index_build_block.cpp +++ b/src/mongo/db/catalog/index_build_block.cpp @@ -45,6 +45,7 @@ #include "mongo/db/query/collection_index_usage_tracker_decoration.h" #include "mongo/db/query/collection_query_info.h" #include "mongo/db/storage/durable_catalog.h" +#include "mongo/db/storage/storage_parameters_gen.h" #include "mongo/db/ttl_collection_cache.h" #include "mongo/db/vector_clock.h" #include "mongo/logv2/log.h" @@ -58,7 +59,14 @@ IndexBuildBlock::IndexBuildBlock(const NamespaceString& nss, const BSONObj& spec, IndexBuildMethod method, boost::optional<UUID> indexBuildUUID) - : _nss(nss), _spec(spec.getOwned()), _method(method), _buildUUID(indexBuildUUID) {} + : _nss(nss), + _spec(spec.getOwned()), + _method(method), + _buildUUID(indexBuildUUID), + _pooledBuilder( + gOperationMemoryPoolBlockInitialSizeKB.loadRelaxed() * static_cast<size_t>(1024), + SharedBufferFragmentBuilder::DoubleGrowStrategy( + gOperationMemoryPoolBlockMaxSizeKB.loadRelaxed() * static_cast<size_t>(1024))) {} void IndexBuildBlock::finalizeTemporaryTables(OperationContext* opCtx, TemporaryRecordStore::FinalizationAction action) { diff --git a/src/mongo/db/catalog/index_build_block.h b/src/mongo/db/catalog/index_build_block.h index d248df83eab..588207a9957 100644 --- a/src/mongo/db/catalog/index_build_block.h +++ b/src/mongo/db/catalog/index_build_block.h @@ -115,6 +115,13 @@ public: return _spec; } + /** + * Returns a memory pool for creating temporary objects for this index build. + */ + SharedBufferFragmentBuilder& getPooledBuilder() { + return _pooledBuilder; + } + private: void _completeInit(OperationContext* opCtx, Collection* collection); @@ -128,5 +135,7 @@ private: std::string _indexNamespace; std::unique_ptr<IndexBuildInterceptor> _indexBuildInterceptor; + + SharedBufferFragmentBuilder _pooledBuilder; }; } // namespace mongo diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 11aa43b14a1..a090f88ce14 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -1369,6 +1369,7 @@ Status IndexCatalogImpl::_indexFilteredRecords(OperationContext* opCtx, const IndexCatalogEntry* index, const std::vector<BsonRecord>& bsonRecords, int64_t* keysInsertedOut) const { + SharedBufferFragmentBuilder pooledBuilder(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); auto& executionCtx = StorageExecutionContext::get(opCtx); InsertDeleteOptions options; @@ -1387,7 +1388,7 @@ Status IndexCatalogImpl::_indexFilteredRecords(OperationContext* opCtx, auto multikeyMetadataKeys = executionCtx.multikeyMetadataKeys(); auto multikeyPaths = executionCtx.multikeyPaths(); - index->accessMethod()->getKeys(executionCtx.pooledBufferBuilder(), + index->accessMethod()->getKeys(pooledBuilder, *bsonRecord.docPtr, options.getKeysMode, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -1552,13 +1553,14 @@ void IndexCatalogImpl::_unindexRecord(OperationContext* opCtx, const RecordId& loc, bool logIfError, int64_t* keysDeletedOut) const { + SharedBufferFragmentBuilder pooledBuilder(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); auto& executionCtx = StorageExecutionContext::get(opCtx); // There's no need to compute the prefixes of the indexed fields that cause the index to be // multikey when removing a document since the index metadata isn't updated when keys are // deleted. auto keys = executionCtx.keys(); - entry->accessMethod()->getKeys(executionCtx.pooledBufferBuilder(), + entry->accessMethod()->getKeys(pooledBuilder, obj, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp index 95411cd8a89..8cbfbe535d0 100644 --- a/src/mongo/db/catalog/multi_index_block.cpp +++ b/src/mongo/db/catalog/multi_index_block.cpp @@ -661,6 +661,7 @@ Status MultiIndexBlock::_insert(OperationContext* opCtx, // exception. try { idxStatus = _indexes[i].bulk->insert(opCtx, + _indexes[i].block->getPooledBuilder(), doc, loc, _indexes[i].options, diff --git a/src/mongo/db/catalog/validate_adaptor.cpp b/src/mongo/db/catalog/validate_adaptor.cpp index d6216e556e4..9971fc0a5d3 100644 --- a/src/mongo/db/catalog/validate_adaptor.cpp +++ b/src/mongo/db/catalog/validate_adaptor.cpp @@ -90,6 +90,7 @@ Status ValidateAdaptor::validateRecord(OperationContext* opCtx, } auto& executionCtx = StorageExecutionContext::get(opCtx); + SharedBufferFragmentBuilder pool(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); for (const auto& index : _validateState->getIndexes()) { const IndexDescriptor* descriptor = index->descriptor(); @@ -102,7 +103,7 @@ Status ValidateAdaptor::validateRecord(OperationContext* opCtx, auto multikeyMetadataKeys = executionCtx.multikeyMetadataKeys(); auto documentMultikeyPaths = executionCtx.multikeyPaths(); - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pool, recordBson, IndexAccessMethod::GetKeysMode::kEnforceConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -278,13 +279,9 @@ void ValidateAdaptor::traverseIndex(OperationContext* opCtx, const KeyString::Version version = index->accessMethod()->getSortedDataInterface()->getKeyStringVersion(); - auto& executionCtx = StorageExecutionContext::get(opCtx); - KeyString::PooledBuilder firstKeyStringBuilder(executionCtx.pooledBufferBuilder(), - version, - BSONObj(), - indexInfo.ord, - KeyString::Discriminator::kExclusiveBefore); - KeyString::Value firstKeyString = firstKeyStringBuilder.release(); + KeyString::Builder firstKeyStringBuilder( + version, BSONObj(), indexInfo.ord, KeyString::Discriminator::kExclusiveBefore); + KeyString::Value firstKeyString = firstKeyStringBuilder.getValueCopy(); KeyString::Value prevIndexKeyStringValue; // Ensure that this index has an open index cursor. diff --git a/src/mongo/db/exec/working_set_common.cpp b/src/mongo/db/exec/working_set_common.cpp index a96bac88dfc..30520e2620e 100644 --- a/src/mongo/db/exec/working_set_common.cpp +++ b/src/mongo/db/exec/working_set_common.cpp @@ -139,12 +139,13 @@ bool WorkingSetCommon::fetch(OperationContext* opCtx, } auto keys = executionCtx.keys(); + SharedBufferFragmentBuilder pool(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // There's no need to compute the prefixes of the indexed fields that cause the // index to be multikey when ensuring the keyData is still valid. KeyStringSet* multikeyMetadataKeys = nullptr; MultikeyPaths* multikeyPaths = nullptr; auto* iam = workingSet->retrieveIndexAccessMethod(memberKey.indexId); - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pool, member->doc.value().toBson(), IndexAccessMethod::GetKeysMode::kEnforceConstraints, IndexAccessMethod::GetKeysContext::kValidatingKeys, diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index f6f1386baab..8341b81c73d 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -120,6 +120,7 @@ AbstractIndexAccessMethod::AbstractIndexAccessMethod(const IndexCatalogEntry* bt // Find the keys for obj, put them in the tree pointing to loc. Status AbstractIndexAccessMethod::insert(OperationContext* opCtx, + SharedBufferFragmentBuilder& pooledBufferBuilder, const CollectionPtr& coll, const BSONObj& obj, const RecordId& loc, @@ -134,7 +135,7 @@ Status AbstractIndexAccessMethod::insert(OperationContext* opCtx, auto multikeyMetadataKeys = executionCtx.multikeyMetadataKeys(); auto multikeyPaths = executionCtx.multikeyPaths(); - getKeys(executionCtx.pooledBufferBuilder(), + getKeys(pooledBufferBuilder, obj, options.getKeysMode, GetKeysContext::kAddingKeys, @@ -273,12 +274,14 @@ RecordId AbstractIndexAccessMethod::findSingle(OperationContext* opCtx, KeyString::Value actualKey = [&]() { if (_indexCatalogEntry->getCollator()) { // For performance, call get keys only if there is a non-simple collation. + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); auto& executionCtx = StorageExecutionContext::get(opCtx); auto keys = executionCtx.keys(); KeyStringSet* multikeyMetadataKeys = nullptr; MultikeyPaths* multikeyPaths = nullptr; - getKeys(executionCtx.pooledBufferBuilder(), + getKeys(pooledBuilder, requestedKey, GetKeysMode::kEnforceConstraints, GetKeysContext::kAddingKeys, @@ -385,7 +388,7 @@ void AbstractIndexAccessMethod::prepareUpdate(OperationContext* opCtx, const RecordId& record, const InsertDeleteOptions& options, UpdateTicket* ticket) const { - auto& executionCtx = StorageExecutionContext::get(opCtx); + SharedBufferFragmentBuilder pooledBuilder(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); const MatchExpression* indexFilter = index->getFilterExpression(); if (!indexFilter || indexFilter->matchesBSON(from)) { // Override key constraints when generating keys for removal. This only applies to keys @@ -397,7 +400,7 @@ void AbstractIndexAccessMethod::prepareUpdate(OperationContext* opCtx, // There's no need to compute the prefixes of the indexed fields that possibly caused the // index to be multikey when the old version of the document was written since the index // metadata isn't updated when keys are deleted. - getKeys(executionCtx.pooledBufferBuilder(), + getKeys(pooledBuilder, from, getKeysMode, GetKeysContext::kRemovingKeys, @@ -409,7 +412,7 @@ void AbstractIndexAccessMethod::prepareUpdate(OperationContext* opCtx, } if (!indexFilter || indexFilter->matchesBSON(to)) { - getKeys(executionCtx.pooledBufferBuilder(), + getKeys(pooledBuilder, to, options.getKeysMode, GetKeysContext::kAddingKeys, @@ -488,6 +491,7 @@ public: StringData dbName); Status insert(OperationContext* opCtx, + SharedBufferFragmentBuilder& pooledBuilder, const BSONObj& obj, const RecordId& loc, const InsertDeleteOptions& options, @@ -564,6 +568,7 @@ AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEn Status AbstractIndexAccessMethod::BulkBuilderImpl::insert( OperationContext* opCtx, + SharedBufferFragmentBuilder& pooledBuilder, const BSONObj& obj, const RecordId& loc, const InsertDeleteOptions& options, @@ -576,7 +581,7 @@ Status AbstractIndexAccessMethod::BulkBuilderImpl::insert( try { _indexCatalogEntry->accessMethod()->getKeys( - executionCtx.pooledBufferBuilder(), + pooledBuilder, obj, options.getKeysMode, GetKeysContext::kAddingKeys, diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 0bb6d04623e..ea1004ee678 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -88,6 +88,7 @@ public: * The behavior of the insertion can be specified through 'options'. */ virtual Status insert(OperationContext* opCtx, + SharedBufferFragmentBuilder& pooledBufferBuilder, const CollectionPtr& coll, const BSONObj& obj, const RecordId& loc, @@ -249,6 +250,7 @@ public: * have to save/restore around each insert() call just in case there is a side table write. */ virtual Status insert(OperationContext* opCtx, + SharedBufferFragmentBuilder& pooledBuilder, const BSONObj& obj, const RecordId& loc, const InsertDeleteOptions& options, @@ -472,6 +474,7 @@ public: std::unique_ptr<SortedDataInterface> btree); Status insert(OperationContext* opCtx, + SharedBufferFragmentBuilder& pooledBufferBuilder, const CollectionPtr& coll, const BSONObj& obj, const RecordId& loc, diff --git a/src/mongo/db/index/skipped_record_tracker.cpp b/src/mongo/db/index/skipped_record_tracker.cpp index 7891cda5478..c86b825663f 100644 --- a/src/mongo/db/index/skipped_record_tracker.cpp +++ b/src/mongo/db/index/skipped_record_tracker.cpp @@ -133,6 +133,7 @@ Status SkippedRecordTracker::retrySkippedRecords(OperationContext* opCtx, CurOp::get(opCtx)->setProgress_inlock(curopMessage, _skippedRecordCounter.load(), 1)); } + SharedBufferFragmentBuilder pooledBuilder(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); auto recordStore = _skippedRecordsTable->rs(); auto cursor = recordStore->getCursor(opCtx); int resolved = 0; @@ -158,8 +159,14 @@ Status SkippedRecordTracker::retrySkippedRecords(OperationContext* opCtx, // Because constraint enforcement is set, this will throw if there are any indexing // errors, instead of writing back to the skipped records table, which would // normally happen if constraints were relaxed. - auto status = _indexCatalogEntry->accessMethod()->insert( - opCtx, collection, skippedDoc, skippedRecordId, options, nullptr, nullptr); + auto status = _indexCatalogEntry->accessMethod()->insert(opCtx, + pooledBuilder, + collection, + skippedDoc, + skippedRecordId, + options, + nullptr, + nullptr); if (!status.isOK()) { return status; } diff --git a/src/mongo/db/query/sbe_stage_builder.cpp b/src/mongo/db/query/sbe_stage_builder.cpp index 47832fa54ba..bfdd8918a42 100644 --- a/src/mongo/db/query/sbe_stage_builder.cpp +++ b/src/mongo/db/query/sbe_stage_builder.cpp @@ -572,13 +572,15 @@ bool indexKeyConsistencyCheckCallback(OperationContext* opCtx, auto& executionCtx = StorageExecutionContext::get(opCtx); auto keys = executionCtx.keys(); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // There's no need to compute the prefixes of the indexed fields that cause the // index to be multikey when ensuring the keyData is still valid. KeyStringSet* multikeyMetadataKeys = nullptr; MultikeyPaths* multikeyPaths = nullptr; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, nextRecord.data.toBson(), IndexAccessMethod::GetKeysMode::kEnforceConstraints, IndexAccessMethod::GetKeysContext::kValidatingKeys, diff --git a/src/mongo/db/storage/execution_context.cpp b/src/mongo/db/storage/execution_context.cpp index b6035493734..a18cd3edc16 100644 --- a/src/mongo/db/storage/execution_context.cpp +++ b/src/mongo/db/storage/execution_context.cpp @@ -34,10 +34,6 @@ namespace mongo { const OperationContext::Decoration<StorageExecutionContext> StorageExecutionContext::get = OperationContext::declareDecoration<StorageExecutionContext>(); -StorageExecutionContext::StorageExecutionContext() - : _pooledBufferBuilder( - gOperationMemoryPoolBlockInitialSizeKB.loadRelaxed() * static_cast<size_t>(1024), - SharedBufferFragmentBuilder::DoubleGrowStrategy( - gOperationMemoryPoolBlockMaxSizeKB.loadRelaxed() * static_cast<size_t>(1024))) {} +StorageExecutionContext::StorageExecutionContext() {} } // namespace mongo diff --git a/src/mongo/db/storage/execution_context.h b/src/mongo/db/storage/execution_context.h index 962eeffe4e5..28479f833b9 100644 --- a/src/mongo/db/storage/execution_context.h +++ b/src/mongo/db/storage/execution_context.h @@ -33,7 +33,6 @@ #include "mongo/db/operation_context.h" #include "mongo/db/storage/key_string.h" #include "mongo/util/auto_clear_ptr.h" -#include "mongo/util/shared_buffer_fragment.h" namespace mongo { @@ -53,10 +52,6 @@ public: StorageExecutionContext& operator=(const StorageExecutionContext&) = delete; StorageExecutionContext& operator=(StorageExecutionContext&&) = delete; - SharedBufferFragmentBuilder& pooledBufferBuilder() { - return _pooledBufferBuilder; - } - AutoClearPtr<KeyStringSet> keys() { return makeAutoClearPtr(&_keys); } @@ -68,7 +63,6 @@ public: } private: - SharedBufferFragmentBuilder _pooledBufferBuilder; KeyStringSet _keys; KeyStringSet _multikeyMetadataKeys; MultikeyPaths _multikeyPaths; diff --git a/src/mongo/dbtests/validate_tests.cpp b/src/mongo/dbtests/validate_tests.cpp index 2939e8c2bb5..46ea3e941db 100644 --- a/src/mongo/dbtests/validate_tests.cpp +++ b/src/mongo/dbtests/validate_tests.cpp @@ -808,7 +808,8 @@ public: return; } - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection, insert three records and check it's valid. lockDb(MODE_X); @@ -860,7 +861,7 @@ public: options.logIfError = true; KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -872,8 +873,8 @@ public: auto removeStatus = iam->removeKeys(&_opCtx, {keys.begin(), keys.end()}, id1, options, &numDeleted); - auto insertStatus = - iam->insert(&_opCtx, coll, badKey, id1, options, nullptr, &numInserted); + auto insertStatus = iam->insert( + &_opCtx, pooledBuilder, coll, badKey, id1, options, nullptr, &numInserted); ASSERT_EQUALS(numDeleted, 1); ASSERT_EQUALS(numInserted, 1); @@ -1204,7 +1205,8 @@ public: return; } - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -1262,7 +1264,7 @@ public: options.dupsAllowed = true; KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -1586,7 +1588,8 @@ public: ValidateMissingIndexEntryRepair() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -1644,7 +1647,7 @@ public: options.dupsAllowed = true; KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -1919,7 +1922,8 @@ public: : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert a document. lockDb(MODE_X); @@ -1989,7 +1993,7 @@ public: auto interceptor = std::make_unique<IndexBuildInterceptor>(&_opCtx, entry); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, dupObj, IndexAccessMethod::GetKeysMode::kRelaxConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -2045,7 +2049,7 @@ public: const BSONObj actualKey = BSON("a" << 1); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2136,8 +2140,8 @@ public: : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert non-multikey document. lockDb(MODE_X); @@ -2182,7 +2186,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, doc, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2315,7 +2319,8 @@ public: ValidateDuplicateDocumentIndexKeySet() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -2385,7 +2390,7 @@ public: options.dupsAllowed = true; KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2422,7 +2427,7 @@ public: options.dupsAllowed = true; KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2459,7 +2464,8 @@ public: return; } - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -2535,7 +2541,7 @@ public: auto interceptor = std::make_unique<IndexBuildInterceptor>(&_opCtx, entry); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, dupObj, IndexAccessMethod::GetKeysMode::kRelaxConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -2587,7 +2593,7 @@ public: auto interceptor = std::make_unique<IndexBuildInterceptor>(&_opCtx, entry); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, dupObj, IndexAccessMethod::GetKeysMode::kRelaxConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -2892,8 +2898,8 @@ public: ValidateIndexWithMultikeyDocRepair() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert non-multikey document. lockDb(MODE_X); @@ -2938,7 +2944,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, doc, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2972,7 +2978,7 @@ public: WriteUnitOfWork wunit(&_opCtx); KeyStringSet keys; MultikeyPaths multikeyPaths; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, mkDoc, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -3114,8 +3120,8 @@ public: ValidateMultikeyPathCoverageRepair() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert multikey document. lockDb(MODE_X); @@ -3163,7 +3169,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, doc1, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -3198,7 +3204,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); KeyStringSet keys; - iam->getKeys(executionCtx.pooledBufferBuilder(), + iam->getKeys(pooledBuilder, doc2, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kAddingKeys, |