summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-05-15 15:20:28 -0400
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-05-15 15:36:40 -0400
commitbae6f255cb2c99d557f02d3861c4abb654fe3071 (patch)
tree3f1d339a147fb98dfcac28b3dbb7fa6b0f50c301 /src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
parent9af1defd2b1b831322e716baa8a4e54b27bd534a (diff)
downloadmongo-bae6f255cb2c99d557f02d3861c4abb654fe3071.tar.gz
SERVER-37988 Recover locks on step up at the beginning of the state transition rather than at the end
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_external_state_impl.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp9
1 files changed, 3 insertions, 6 deletions
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 2e163ee30ea..b331991dd89 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -463,6 +463,8 @@ OpTime ReplicationCoordinatorExternalStateImpl::onTransitionToPrimary(OperationC
invariant(opCtx->lockState()->isRSTLExclusive());
invariant(!opCtx->shouldParticipateInFlowControl());
+ MongoDSessionCatalog::onStepUp(opCtx);
+
// Clear the appliedThrough marker so on startup we'll use the top of the oplog. This must be
// done before we add anything to our oplog.
// We record this update at the 'lastAppliedOpTime'. If there are any outstanding
@@ -489,15 +491,10 @@ OpTime ReplicationCoordinatorExternalStateImpl::onTransitionToPrimary(OperationC
fassert(28665, loadLastOpTimeAndWallTimeResult);
auto opTimeToReturn = loadLastOpTimeAndWallTimeResult.getValue().opTime;
-
_shardingOnTransitionToPrimaryHook(opCtx);
- // This has to go before reaquiring locks for prepared transactions, otherwise this can be
- // blocked by prepared transactions.
_dropAllTempCollections(opCtx);
- MongoDSessionCatalog::onStepUp(opCtx);
-
notifyFreeMonitoringOnTransitionToPrimary();
// It is only necessary to check the system indexes on the first transition to master.
@@ -834,7 +831,7 @@ void ReplicationCoordinatorExternalStateImpl::_dropAllTempCollections(OperationC
if (*it == "local")
continue;
LOG(2) << "Removing temporary collections from " << *it;
- AutoGetDb autoDb(opCtx, *it, MODE_X);
+ AutoGetDb autoDb(opCtx, *it, MODE_IX);
invariant(autoDb.getDb(), str::stream() << "Unable to get reference to database " << *it);
autoDb.getDb()->clearTmpCollections(opCtx);
}