summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2018-04-27 16:09:09 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2018-04-27 17:23:21 -0400
commit2227f272a7a0a3e43625cb2d4a2704e1ccb6f893 (patch)
treeeeb3a3fe22df48b6819a5d7e719befd680b3dedc /src/mongo/db/repl
parent7c25d109bda4c56cc329ee4f1a1521a2f9bc690a (diff)
downloadmongo-2227f272a7a0a3e43625cb2d4a2704e1ccb6f893.tar.gz
SERVER-32645 Create a shim helper framework.
The `MONGO_DECLARE_SHIM`, `MONGO_DEFINE_SHIM`, and `MONGO_REGISTER_SHIM` macros can be used to create specialized types which are customization and auto-registration points for late-binding functions. In some sense they work like weak-symbols; however, they also are useful for tracking dependencies upon shimmed-out implementations.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/apply_ops.cpp4
-rw-r--r--src/mongo/db/repl/oplog.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp4
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp2
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.cpp6
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp4
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp4
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp2
-rw-r--r--src/mongo/db/repl/sync_tail.cpp2
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp5
10 files changed, 19 insertions, 18 deletions
diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp
index 3a732c407ec..81ebf365c62 100644
--- a/src/mongo/db/repl/apply_ops.cpp
+++ b/src/mongo/db/repl/apply_ops.cpp
@@ -137,7 +137,7 @@ Status _applyOps(OperationContext* opCtx,
invariant(opCtx->lockState()->isW());
invariant(*opType != 'c');
- auto db = dbHolder().get(opCtx, nss.ns());
+ auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.ns());
if (!db) {
// Retry in non-atomic mode, since MMAP cannot implicitly create a new database
// within an active WriteUnitOfWork.
@@ -339,7 +339,7 @@ Status _checkPrecondition(OperationContext* opCtx,
BSONObj realres = db.findOne(nss.ns(), preCondition["q"].Obj());
// Get collection default collation.
- Database* database = dbHolder().get(opCtx, nss.db());
+ Database* database = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db());
if (!database) {
return {ErrorCodes::NamespaceNotFound, "database in ns does not exist: " + nss.ns()};
}
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 6e083990f4e..2c6f4395590 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -227,7 +227,7 @@ void createIndexForApplyOps(OperationContext* opCtx,
IncrementOpsAppliedStatsFn incrementOpsAppliedStats,
OplogApplication::Mode mode) {
// Check if collection exists.
- Database* db = dbHolder().get(opCtx, indexNss.ns());
+ Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, indexNss.ns());
auto indexCollection = db ? db->getCollection(opCtx, indexNss) : nullptr;
uassert(ErrorCodes::NamespaceNotFound,
str::stream() << "Failed to create index due to missing collection: " << indexNss.ns(),
@@ -1516,7 +1516,7 @@ Status applyCommand_inlock(OperationContext* opCtx,
return {ErrorCodes::InvalidNamespace, "invalid ns: " + std::string(nss.ns())};
}
{
- Database* db = dbHolder().get(opCtx, nss.ns());
+ Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.ns());
if (db && !db->getCollection(opCtx, nss) && db->getViewCatalog()->lookup(opCtx, nss.ns())) {
return {ErrorCodes::CommandNotSupportedOnView,
str::stream() << "applyOps not supported on view:" << nss.ns()};
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index bb87c7312d7..1fb7bea1adf 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -394,7 +394,7 @@ Status ReplicationCoordinatorExternalStateImpl::runRepairOnLocalDB(OperationCont
Status status = repairDatabase(opCtx, engine, localDbName, false, false);
// Open database before returning
- dbHolder().openDb(opCtx, localDbName);
+ DatabaseHolder::getDatabaseHolder().openDb(opCtx, localDbName);
} catch (const DBException& ex) {
return ex.toStatus();
}
@@ -787,7 +787,7 @@ void ReplicationCoordinatorExternalStateImpl::_dropAllTempCollections(OperationC
if (*it == "local")
continue;
LOG(2) << "Removing temporary collections from " << *it;
- Database* db = dbHolder().get(opCtx, *it);
+ Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, *it);
// Since we must be holding the global lock during this function, if listDatabases
// returned this dbname, we should be able to get a reference to it - it can't have
// been dropped.
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index e92b0c9ab2d..6e96e6d0237 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -857,7 +857,7 @@ void RollbackImpl::_resetDropPendingState(OperationContext* opCtx) {
opCtx->getServiceContext()->getGlobalStorageEngine()->listDatabases(&dbNames);
for (const auto& dbName : dbNames) {
Lock::DBLock dbLock(opCtx, dbName, MODE_X);
- Database* db = dbHolder().openDb(opCtx, dbName);
+ Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName);
checkForIdIndexesAndDropPendingCollections(opCtx, db);
}
}
diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp
index 2e9c4f47889..b0d49b1473a 100644
--- a/src/mongo/db/repl/rollback_test_fixture.cpp
+++ b/src/mongo/db/repl/rollback_test_fixture.cpp
@@ -102,8 +102,8 @@ void RollbackTest::tearDown() {
SessionCatalog::get(_serviceContextMongoDTest.getServiceContext())->reset_forTest();
// We cannot unset the global replication coordinator because ServiceContextMongoD::tearDown()
- // calls dropAllDatabasesExceptLocal() which requires the replication coordinator to clear all
- // snapshots.
+ // calls Databse::dropAllDatabasesExceptLocal() which requires the replication coordinator to
+ // clear all snapshots.
_serviceContextMongoDTest.tearDown();
// ServiceContextMongoD::tearDown() does not destroy service context so it is okay
@@ -179,7 +179,7 @@ Collection* RollbackTest::_createCollection(OperationContext* opCtx,
const CollectionOptions& options) {
Lock::DBLock dbLock(opCtx, nss.db(), MODE_X);
mongo::WriteUnitOfWork wuow(opCtx);
- auto db = dbHolder().openDb(opCtx, nss.db());
+ auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, nss.db());
ASSERT_TRUE(db);
db->dropCollection(opCtx, nss.ns()).transitional_ignore();
auto coll = db->createCollection(opCtx, nss.ns(), options);
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 3e9944988ba..eae8c70a468 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -844,7 +844,7 @@ void rollbackRenameCollection(OperationContext* opCtx, UUID uuid, RenameCollecti
log() << "Attempting to rename collection with UUID: " << uuid << ", from: " << info.renameFrom
<< ", to: " << info.renameTo;
Lock::DBLock dbLock(opCtx, dbName, MODE_X);
- auto db = dbHolder().openDb(opCtx, dbName);
+ auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName);
invariant(db);
auto status = renameCollectionForRollback(opCtx, info.renameTo, uuid);
@@ -1138,7 +1138,7 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
Lock::DBLock dbLock(opCtx, nss.db(), MODE_X);
- auto db = dbHolder().openDb(opCtx, nss.db().toString());
+ auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, nss.db().toString());
invariant(db);
Collection* collection = UUIDCatalog::get(opCtx).lookupCollectionByUUID(uuid);
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index b4858df9cba..93a47ec8044 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -357,7 +357,7 @@ int _testRollbackDelete(OperationContext* opCtx,
Lock::DBLock dbLock(opCtx, "test", MODE_S);
Lock::CollectionLock collLock(opCtx->lockState(), "test.t", MODE_S);
- auto db = dbHolder().get(opCtx, "test");
+ auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, "test");
ASSERT_TRUE(db);
auto collection = db->getCollection(opCtx, "test.t");
if (!collection) {
@@ -1777,7 +1777,7 @@ TEST_F(RSRollbackTest, RollbackCreateCollectionCommand) {
_replicationProcess.get()));
{
Lock::DBLock dbLock(_opCtx.get(), "test", MODE_S);
- auto db = dbHolder().get(_opCtx.get(), "test");
+ auto db = DatabaseHolder::getDatabaseHolder().get(_opCtx.get(), "test");
ASSERT_TRUE(db);
ASSERT_FALSE(db->getCollection(_opCtx.get(), "test.t"));
}
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index e4a53344305..cd9dbcc1fd1 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -370,7 +370,7 @@ Status StorageInterfaceImpl::insertDocuments(OperationContext* opCtx,
}
Status StorageInterfaceImpl::dropReplicatedDatabases(OperationContext* opCtx) {
- dropAllDatabasesExceptLocal(opCtx);
+ Database::dropAllDatabasesExceptLocal(opCtx);
return Status::OK();
}
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 1dd997ce5a8..b70f3c56793 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -542,7 +542,7 @@ private:
CollectionProperties collProperties;
Lock::DBLock dbLock(opCtx, nsToDatabaseSubstring(ns), MODE_IS);
- auto db = dbHolder().get(opCtx, ns);
+ auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, ns);
if (!db) {
return collProperties;
}
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 3740407529a..d995e4f61e2 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -193,7 +193,7 @@ auto createCollectionWithUuid(OperationContext* opCtx, const NamespaceString& ns
void createDatabase(OperationContext* opCtx, StringData dbName) {
Lock::GlobalWrite globalLock(opCtx);
bool justCreated;
- Database* db = dbHolder().openDb(opCtx, dbName, &justCreated);
+ Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName, &justCreated);
ASSERT_TRUE(db);
ASSERT_TRUE(justCreated);
}
@@ -991,7 +991,8 @@ TEST_F(SyncTailTest, MultiInitialSyncApplyIgnoresUpdateOperationIfDocumentIsMiss
{
Lock::GlobalWrite globalLock(_opCtx.get());
bool justCreated = false;
- Database* db = dbHolder().openDb(_opCtx.get(), nss.db(), &justCreated);
+ Database* db =
+ DatabaseHolder::getDatabaseHolder().openDb(_opCtx.get(), nss.db(), &justCreated);
ASSERT_TRUE(db);
ASSERT_TRUE(justCreated);
}