summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2023-03-14 18:17:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-14 22:56:56 +0000
commit3abc47813a2bad4918013fe441f14a4abb757fd7 (patch)
treefac1a283450105ffccbcc90124c1f7f4895c2e78 /src/mongo/db/catalog
parent93ba22f8e66229fe0c51167b8ab14589200f0127 (diff)
downloadmongo-3abc47813a2bad4918013fe441f14a4abb757fd7.tar.gz
SERVER-74823 IndexCatalog initialization should not assume all non-ready indexes are two-phase index builds
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 16e3182e697..fa09ca50c55 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -263,13 +263,21 @@ void IndexCatalogImpl::init(OperationContext* opCtx,
bool ready = collection->isIndexReady(indexName);
if (!ready) {
- auto buildUUID = collection->getIndexBuildUUID(indexName);
- invariant(buildUUID,
- str::stream() << "collection: " << collection->ns() << "index:" << indexName);
+ if (!isPointInTimeRead) {
+ // When initializing the indexes at the latest timestamp for existing collections,
+ // the only non-ready indexes will be two-phase index builds. Unfinished
+ // single-phase index builds are dropped during startup and rollback.
+ auto buildUUID = collection->getIndexBuildUUID(indexName);
+ invariant(buildUUID,
+ str::stream()
+ << "collection: " << collection->ns() << "index:" << indexName);
+ }
+
// We intentionally do not drop or rebuild unfinished two-phase index builds before
// initializing the IndexCatalog when starting a replica set member in standalone mode.
// This is because the index build cannot complete until it receives a replicated commit
- // or abort oplog entry.
+ // or abort oplog entry. When performing a point-in-time read, this non-ready index may
+ // represent a single-phase index build.
if (replSetMemberInStandaloneMode) {
// Indicate that this index is "frozen". It is not ready but is not currently in
// progress either. These indexes may be dropped.