Skip to content

Commit a6424fa

Browse files
GWlodarekEvergreen Agent
authored andcommitted
SERVER-47700 renameCollection should check if the target collection exists before accessing the collection object
1 parent f0cd3af commit a6424fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/mongo/db/catalog/database_impl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,13 @@ Status DatabaseImpl::renameCollection(OperationContext* opCtx,
547547

548548
Collection* toColl =
549549
CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, toNss);
550-
invariant(
551-
!toColl->getIndexCatalog()->haveAnyIndexesInProgress(),
552-
str::stream() << "cannot perform operation: an index build is currently running for "
550+
if (toColl) {
551+
invariant(!toColl->getIndexCatalog()->haveAnyIndexesInProgress(),
552+
str::stream()
553+
<< "cannot perform operation: an index build is currently running for "
553554
"collection "
554555
<< toNss);
556+
}
555557
}
556558

557559
LOGV2(20319,

0 commit comments

Comments
 (0)