void ServiceContextMongoDTest::_dropAllDBs(OperationContext* txn) { dropAllDatabasesExceptLocal(txn); ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); AutoGetDb autoDBLocal(txn, "local", MODE_X); const auto localDB = autoDBLocal.getDb(); if (localDB) { MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { // Do not wrap in a WriteUnitOfWork until SERVER-17103 is addressed. autoDBLocal.getDb()->dropDatabase(txn, localDB); } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "_dropAllDBs", "local"); } }
void ServiceContextMongoDTest::_dropAllDBs(OperationContext* opCtx) { dropAllDatabasesExceptLocal(opCtx); Lock::GlobalWrite lk(opCtx); AutoGetDb autoDBLocal(opCtx, "local", MODE_X); const auto localDB = autoDBLocal.getDb(); if (localDB) { writeConflictRetry(opCtx, "_dropAllDBs", "local", [&] { // Do not wrap in a WriteUnitOfWork until SERVER-17103 is addressed. autoDBLocal.getDb()->dropDatabase(opCtx, localDB); }); } // dropAllDatabasesExceptLocal() does not close empty databases. However the holder still // allocates resources to track these empty databases. These resources not released by // dropAllDatabasesExceptLocal() will be leaked at exit unless we call DatabaseHolder::closeAll. dbHolder().closeAll(opCtx, "all databases dropped"); }
void ServiceContextMongoDTest::_dropAllDBs(OperationContext* txn) { dropAllDatabasesExceptLocal(txn); ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); AutoGetDb autoDBLocal(txn, "local", MODE_X); const auto localDB = autoDBLocal.getDb(); if (localDB) { MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { // Do not wrap in a WriteUnitOfWork until SERVER-17103 is addressed. autoDBLocal.getDb()->dropDatabase(txn, localDB); } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "_dropAllDBs", "local"); } // dropAllDatabasesExceptLocal() does not close empty databases. However the holder still // allocates resources to track these empty databases. These resources not released by // dropAllDatabasesExceptLocal() will be leaked at exit unless we call DatabaseHolder::closeAll. BSONObjBuilder unused; invariant(dbHolder().closeAll(txn, unused, false)); }