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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.3.14
    • None
    • Replication
    • None
    • Fully Compatible
    • Repl 2016-09-19

    Description

      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());
      }
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: