[SERVER-26151] StorageInterfaceImpl::dropCollection() shouldn't create the database if it doesn't exist Created: 16/Sep/16  Updated: 25/Jan/17  Resolved: 19/Sep/16

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.3.14

Type: Improvement Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Repl 2016-09-19
Participants:

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



 Comments   
Comment by Githook User [ 19/Sep/16 ]

Author:

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

Message: SERVER-26151 StorageInterfaceImpl::dropCollection() shouldn't create the database if it doesn't exist
Branch: master
https://github.com/mongodb/mongo/commit/35fdb2f02359c3a7fc42c4dffbdc7f47b5ad48ab

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