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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.14
    • Component/s: Replication
    • Labels:
      None

      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

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: