@@ -331,11 +331,14 @@ bool StorageEngineImpl::_handleInternalIdents(
331
331
const std::string& ident,
332
332
InternalIdentReconcilePolicy internalIdentReconcilePolicy,
333
333
ReconcileResult* reconcileResult,
334
- std::set<std::string>* internalIdentsToDrop) {
334
+ std::set<std::string>* internalIdentsToDrop,
335
+ std::set<std::string>* allInternalIdents) {
335
336
if (!_catalog->isInternalIdent (ident)) {
336
337
return false ;
337
338
}
338
339
340
+ allInternalIdents->insert (ident);
341
+
339
342
if (InternalIdentReconcilePolicy::kDrop == internalIdentReconcilePolicy ||
340
343
!supportsResumableIndexBuilds ()) {
341
344
internalIdentsToDrop->insert (ident);
@@ -378,8 +381,6 @@ bool StorageEngineImpl::_handleInternalIdents(
378
381
reconcileResult->indexBuildsToResume .push_back (resumeInfo);
379
382
380
383
// Once we have parsed the resume info, we can safely drop the internal ident.
381
- // TODO SERVER-49846: revisit this logic since this could cause the side tables
382
- // associated with the index build to be orphaned if resuming fails.
383
384
internalIdentsToDrop->insert (ident);
384
385
385
386
LOGV2 (4916301 ,
@@ -435,6 +436,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
435
436
catalogIdents.insert (vec.begin (), vec.end ());
436
437
}
437
438
std::set<std::string> internalIdentsToDrop;
439
+ std::set<std::string> allInternalIdents;
438
440
439
441
auto dropPendingIdents = _dropPendingIdentReaper.getAllIdentNames ();
440
442
@@ -446,8 +448,12 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
446
448
continue ;
447
449
}
448
450
449
- if (_handleInternalIdents (
450
- opCtx, it, internalIdentReconcilePolicy, &reconcileResult, &internalIdentsToDrop)) {
451
+ if (_handleInternalIdents (opCtx,
452
+ it,
453
+ internalIdentReconcilePolicy,
454
+ &reconcileResult,
455
+ &internalIdentsToDrop,
456
+ &allInternalIdents)) {
451
457
continue ;
452
458
}
453
459
@@ -623,6 +629,11 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
623
629
}
624
630
}
625
631
632
+ // If there are no index builds to resume, we should drop all internal idents.
633
+ if (reconcileResult.indexBuildsToResume .empty ()) {
634
+ internalIdentsToDrop.swap (allInternalIdents);
635
+ }
636
+
626
637
for (auto && temp : internalIdentsToDrop) {
627
638
LOGV2 (22257 , " Dropping internal ident" , " ident" _attr = temp);
628
639
WriteUnitOfWork wuow (opCtx);
0 commit comments