Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-30369

Database::_getOrCreateCollection() unregisters uuid catalog changes on WUOW rollback

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.11
    • Affects Version/s: None
    • Component/s: Storage
    • None
    • Fully Compatible
    • ALL
    • Repl 2017-07-31
    • 0

      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
          opCtx->recoveryUnit()->registerChange(new AddCollectionChange(opCtx, this, ns));
          Collection* collection = _getOrCreateCollectionInstance(opCtx, nss);
          invariant(collection);
          _collections[ns] = collection;
      
          BSONObj fullIdIndexSpec;
      
          if (createIdIndex) {
              if (collection->requiresIdIndex()) {
                  if (optionsWithUUID.autoIndexId == CollectionOptions::YES ||
                      optionsWithUUID.autoIndexId == CollectionOptions::DEFAULT) {
                      const auto featureCompatibilityVersion =
                          serverGlobalParams.featureCompatibility.version.load();
                      IndexCatalog* ic = collection->getIndexCatalog();
                      fullIdIndexSpec = uassertStatusOK(ic->createIndexOnEmptyCollection(
                          opCtx,
                          !idIndex.isEmpty() ? idIndex
                                             : ic->getDefaultIdIndexSpec(featureCompatibilityVersion)));
                  }
              }
      

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            benety.goh@mongodb.com Benety Goh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: