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

StorageInterfaceImpl::dropCollection() shouldn't create the database if it doesn't exist

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.14
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • Repl 2016-09-19

      StorageIntefaceImpl::dropCollection() uses AutoGetOrCreateDb when acquiring a lock on the database to drop the collection. Instead, it should probably use AutoGetDb and bail out if the database doesn't exist.

      Status StorageInterfaceImpl::dropCollection(OperationContext* txn, const NamespaceString& nss) {
          MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
              ScopedTransaction transaction(txn, MODE_IX);
              AutoGetOrCreateDb autoDB(txn, nss.db(), MODE_X);
              WriteUnitOfWork wunit(txn);
              const auto status = autoDB.getDb()->dropCollection(txn, nss.ns());
              if (status.isOK()) {
                  wunit.commit();
              }
              return status;
          }
          MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "StorageInterfaceImpl::dropCollection", nss.ns());
      }
      

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

              Created:
              Updated:
              Resolved: