summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-12 16:12:24 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-15 13:57:07 -0400
commite733c07891c2f1e16320707317eeb28559bdc03f (patch)
tree3996cacafb06f58e2d35f13b779cdc632c84bde9 /src/mongo/db/db_raii.cpp
parent4b23c5793849cb9a6943607d2a55d7306e61eed4 (diff)
downloadmongo-e733c07891c2f1e16320707317eeb28559bdc03f.tar.gz
SERVER-35516 Get rid of OldClientWriteContext
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp50
1 files changed, 1 insertions, 49 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index 529743fbfc4..1262d78444f 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -246,7 +246,6 @@ bool AutoGetCollectionForRead::_conflictingCatalogChanges(
return true;
}
-
AutoGetCollectionForReadCommand::AutoGetCollectionForReadCommand(
OperationContext* opCtx,
const NamespaceStringOrUUID& nsOrUUID,
@@ -268,12 +267,7 @@ AutoGetCollectionForReadCommand::AutoGetCollectionForReadCommand(
}
OldClientContext::OldClientContext(OperationContext* opCtx, const std::string& ns, bool doVersion)
- : OldClientContext(
- opCtx, ns, doVersion, DatabaseHolder::getDatabaseHolder().get(opCtx, ns), false) {}
-
-OldClientContext::OldClientContext(
- OperationContext* opCtx, const std::string& ns, bool doVersion, Database* db, bool justCreated)
- : _opCtx(opCtx), _db(db), _justCreated(justCreated) {
+ : _opCtx(opCtx), _db(DatabaseHolder::getDatabaseHolder().get(opCtx, ns)) {
if (!_db) {
const auto dbName = nsToDatabaseSubstring(ns);
invariant(_opCtx->lockState()->isDbLockedForMode(dbName, MODE_X));
@@ -320,48 +314,6 @@ OldClientContext::~OldClientContext() {
currentOp->getReadWriteType());
}
-
-OldClientWriteContext::OldClientWriteContext(OperationContext* opCtx, StringData ns)
- : _opCtx(opCtx), _nss(ns) {
- // Lock the database and collection
- _autoCreateDb.emplace(opCtx, _nss.db(), MODE_IX);
- _collLock.emplace(opCtx->lockState(), _nss.ns(), MODE_IX);
-
- const bool doShardVersionCheck = false;
-
- _clientContext.emplace(opCtx,
- _nss.ns(),
- doShardVersionCheck,
- _autoCreateDb->getDb(),
- _autoCreateDb->justCreated());
- invariant(_autoCreateDb->getDb() == _clientContext->db());
-
- // If the collection exists, there is no need to lock into stronger mode
- if (getCollection())
- return;
-
- // If the database was just created, it is already locked in MODE_X so we can skip the relocking
- // code below
- if (_autoCreateDb->justCreated()) {
- dassert(opCtx->lockState()->isDbLockedForMode(_nss.db(), MODE_X));
- return;
- }
-
- // If the collection doesn't exists, put the context in a state where the database is locked in
- // MODE_X so that the collection can be created
- _clientContext.reset();
- _collLock.reset();
- _autoCreateDb.reset();
- _autoCreateDb.emplace(opCtx, _nss.db(), MODE_X);
-
- _clientContext.emplace(opCtx,
- _nss.ns(),
- doShardVersionCheck,
- _autoCreateDb->getDb(),
- _autoCreateDb->justCreated());
- invariant(_autoCreateDb->getDb() == _clientContext->db());
-}
-
LockMode getLockModeForQuery(OperationContext* opCtx) {
invariant(opCtx);