[SERVER-30369] Database::_getOrCreateCollection() unregisters uuid catalog changes on WUOW rollback Created: 27/Jul/17  Updated: 30/Oct/23  Resolved: 27/Jul/17

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 3.5.11

Type: Bug Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-30229 Clean up UUIDCatalog registration Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Repl 2017-07-31
Participants:
Linked BF Score: 0

 Description   

In Database::createCollection(), if we uassert on creating the _id index, the AddCollectionChange rollback logic will hit an invariant because the UUID for the collection is not removed from the UUIDCatalog.

https://github.com/mongodb/mongo/blob/6cc2dfe7edd312b8596355edef454e15988e350e/src/mongo/db/catalog/database_impl.cpp#L752

database_impl.cpp

738
    opCtx->recoveryUnit()->registerChange(new AddCollectionChange(opCtx, this, ns));
739
    Collection* collection = _getOrCreateCollectionInstance(opCtx, nss);
740
    invariant(collection);
741
    _collections[ns] = collection;
742
 
743
    BSONObj fullIdIndexSpec;
744
 
745
    if (createIdIndex) {
746
        if (collection->requiresIdIndex()) {
747
            if (optionsWithUUID.autoIndexId == CollectionOptions::YES ||
748
                optionsWithUUID.autoIndexId == CollectionOptions::DEFAULT) {
749
                const auto featureCompatibilityVersion =
750
                    serverGlobalParams.featureCompatibility.version.load();
751
                IndexCatalog* ic = collection->getIndexCatalog();
752
                fullIdIndexSpec = uassertStatusOK(ic->createIndexOnEmptyCollection(
753
                    opCtx,
754
                    !idIndex.isEmpty() ? idIndex
755
                                       : ic->getDefaultIdIndexSpec(featureCompatibilityVersion)));
756
            }
757
        }



 Comments   
Comment by Githook User [ 27/Jul/17 ]

Author:

{'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}

Message: SERVER-30369 Database::_getOrCreateCollection() unregisters uuid catalog changes on WUOW rollback
Branch: master
https://github.com/mongodb/mongo/commit/073215d1a3204d97f86fccced11565091fc7fed5

Generated at Thu Feb 08 04:23:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.