summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2020-06-09 15:47:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-09 18:01:43 +0000
commit8b20e37d7164c8112b6173fc953031a39b59b3c0 (patch)
tree16c6f0d69f34f0b7312f6e3310552100ed9d193c /src
parent1c196c94bd0f2f0b28a4952d6048776940889a94 (diff)
downloadmongo-8b20e37d7164c8112b6173fc953031a39b59b3c0.tar.gz
Revert "SERVER-47645 Must invalidate all sessions on stepdown"
This reverts commit c1bc1b6d6b7b7d216b8243a609f1c7231045e5be.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/kill_sessions_local.cpp20
-rw-r--r--src/mongo/db/kill_sessions_local.h6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp2
-rw-r--r--src/mongo/db/transaction_participant.cpp3
-rw-r--r--src/mongo/db/transaction_validation.cpp4
6 files changed, 2 insertions, 35 deletions
diff --git a/src/mongo/db/kill_sessions_local.cpp b/src/mongo/db/kill_sessions_local.cpp
index d1570e2f2e9..d1b57090e54 100644
--- a/src/mongo/db/kill_sessions_local.cpp
+++ b/src/mongo/db/kill_sessions_local.cpp
@@ -218,24 +218,4 @@ void yieldLocksForPreparedTransactions(OperationContext* opCtx) {
ErrorCodes::InterruptedDueToReplStateChange);
}
-void invalidateSessionsForStepdown(OperationContext* opCtx) {
- // It is illegal to invalidate the sessions if the operation has a session checked out.
- invariant(!OperationContextSession::get(opCtx));
-
- SessionKiller::Matcher matcherAllSessions(
- KillAllSessionsByPatternSet{makeKillAllSessionsByPattern(opCtx)});
- killSessionsAction(opCtx,
- matcherAllSessions,
- [](const ObservableSession& session) {
- return !TransactionParticipant::get(session).transactionIsPrepared();
- },
- [](OperationContext* killerOpCtx, const SessionToKill& session) {
- auto txnParticipant = TransactionParticipant::get(session);
- if (!txnParticipant.transactionIsPrepared()) {
- txnParticipant.invalidate(killerOpCtx);
- }
- },
- ErrorCodes::InterruptedDueToReplStateChange);
-}
-
} // namespace mongo
diff --git a/src/mongo/db/kill_sessions_local.h b/src/mongo/db/kill_sessions_local.h
index e489589bdce..6b4da948e1c 100644
--- a/src/mongo/db/kill_sessions_local.h
+++ b/src/mongo/db/kill_sessions_local.h
@@ -71,10 +71,4 @@ void killSessionsAbortAllPreparedTransactions(OperationContext* opCtx);
*/
void yieldLocksForPreparedTransactions(OperationContext* opCtx);
-/**
- * Invalidates sessions that do not have prepared transactions, since txnNumbers for transactions
- * that were aborted in-memory may be reused on the new primary.
- */
-void invalidateSessionsForStepdown(OperationContext* opCtx);
-
} // namespace mongo
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index db44c70bf5e..3b8f115fb86 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2649,7 +2649,6 @@ void ReplicationCoordinatorImpl::stepDown(OperationContext* opCtx,
lk.unlock();
yieldLocksForPreparedTransactions(opCtx);
- invalidateSessionsForStepdown(opCtx);
lk.lock();
@@ -3430,7 +3429,6 @@ void ReplicationCoordinatorImpl::_finishReplSetReconfig(OperationContext* opCtx,
lk.unlock();
yieldLocksForPreparedTransactions(opCtx);
- invalidateSessionsForStepdown(opCtx);
lk.lock();
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index 9656e642eb0..3c75ccf2843 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -464,7 +464,6 @@ void ReplicationCoordinatorImpl::_stepDownFinish(
lk.unlock();
yieldLocksForPreparedTransactions(opCtx.get());
- invalidateSessionsForStepdown(opCtx.get());
lk.lock();
@@ -744,7 +743,6 @@ void ReplicationCoordinatorImpl::_heartbeatReconfigFinish(
lk.unlock();
yieldLocksForPreparedTransactions(opCtx.get());
- invalidateSessionsForStepdown(opCtx.get());
lk.lock();
diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp
index a151d95a7e5..97453881f18 100644
--- a/src/mongo/db/transaction_participant.cpp
+++ b/src/mongo/db/transaction_participant.cpp
@@ -583,9 +583,6 @@ void TransactionParticipant::Participant::beginOrContinueTransactionUnconditiona
if (o().activeTxnNumber != txnNumber) {
_beginMultiDocumentTransaction(opCtx, txnNumber);
- } else {
- invariant(o().txnState.isInSet(TransactionState::kInProgress | TransactionState::kPrepared),
- str::stream() << "Current state: " << o().txnState);
}
// Assume we need to write an abort if we abort this transaction. This method is called only
diff --git a/src/mongo/db/transaction_validation.cpp b/src/mongo/db/transaction_validation.cpp
index f2360df18b6..9342e07d1b9 100644
--- a/src/mongo/db/transaction_validation.cpp
+++ b/src/mongo/db/transaction_validation.cpp
@@ -53,8 +53,8 @@ const StringMap<int> retryableWriteCommands = {{"delete", 1},
{"_recvChunkStart", 1}};
// Commands that can be sent with session info but should not check out a session.
-const StringMap<int> skipSessionCheckoutList = {
- {"coordinateCommitTransaction", 1}, {"_recvChunkStart", 1}, {"replSetStepDown", 1}};
+const StringMap<int> skipSessionCheckoutList = {{"coordinateCommitTransaction", 1},
+ {"_recvChunkStart", 1}};
const StringMap<int> transactionCommands = {{"commitTransaction", 1},
{"coordinateCommitTransaction", 1},