diff options
author | Yu Jin Kang Park <yujin.kang@mongodb.com> | 2023-05-16 16:03:17 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-16 17:47:14 +0000 |
commit | f1b417202d283df43bd3f9833726097297d34f63 (patch) | |
tree | f1872143317d5db1d3151b41fd8a273020a2c1b8 | |
parent | 8e48a8ff0a091a284f615b6d0c3c8edad292c863 (diff) | |
download | mongo-f1b417202d283df43bd3f9833726097297d34f63.tar.gz |
SERVER-77018 Remove in-progress index builds from getIndexFreeStorageBytes
-rw-r--r-- | src/mongo/db/catalog/collection_impl.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp index e939edf61d2..f5cb5d61a12 100644 --- a/src/mongo/db/catalog/collection_impl.cpp +++ b/src/mongo/db/catalog/collection_impl.cpp @@ -1061,9 +1061,18 @@ uint64_t CollectionImpl::getIndexSize(OperationContext* opCtx, } uint64_t CollectionImpl::getIndexFreeStorageBytes(OperationContext* const opCtx) const { + // Unfinished index builds are excluded to avoid a potential deadlock when trying to collect + // statistics from the index table while the index build is in the bulk load phase. See + // SERVER-77018. This should not be too impactful as: + // - During the collection scan phase, the index table is unused. + // - During the bulk load phase, getFreeStorageBytes will probably return EBUSY, as the ident is + // in use by the index builder. (And worst case results in the deadlock). + // - It might be possible to return meaningful data post bulk-load, but reusable bytes should be + // low anyways as the collection has been bulk loaded. Additionally, this would be a inaccurate + // anyways as the build is in progress. + // - Once the index build is finished, this will be eventually accounted for. const auto idxCatalog = getIndexCatalog(); - auto indexIt = idxCatalog->getIndexIterator( - opCtx, IndexCatalog::InclusionPolicy::kReady | IndexCatalog::InclusionPolicy::kUnfinished); + auto indexIt = idxCatalog->getIndexIterator(opCtx, IndexCatalog::InclusionPolicy::kReady); uint64_t totalSize = 0; while (indexIt->more()) { |