mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
SERVER-37627 Remove the coordinator on abort transaction
This commit is contained in:
parent
6d714be688
commit
00f77c5e43
@ -98,6 +98,13 @@ function enableStaleVersionAndSnapshotRetriesWithinTransactions(st) {
|
||||
configureFailPoint: "enableStaleVersionAndSnapshotRetriesWithinTransactions",
|
||||
mode: "alwaysOn"
|
||||
}));
|
||||
|
||||
st._rs.forEach(function(replTest) {
|
||||
replTest.nodes.forEach(function(node) {
|
||||
assert.commandWorked(node.getDB('admin').runCommand(
|
||||
{configureFailPoint: "dontRemoveTxnCoordinatorOnAbort", mode: "alwaysOn"}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// TODO SERVER-39704: Remove this function.
|
||||
@ -106,6 +113,13 @@ function disableStaleVersionAndSnapshotRetriesWithinTransactions(st) {
|
||||
configureFailPoint: "enableStaleVersionAndSnapshotRetriesWithinTransactions",
|
||||
mode: "off"
|
||||
}));
|
||||
|
||||
st._rs.forEach(function(replTest) {
|
||||
replTest.nodes.forEach(function(node) {
|
||||
assert.commandWorked(node.getDB('admin').runCommand(
|
||||
{configureFailPoint: "dontRemoveTxnCoordinatorOnAbort", mode: "off"}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Flush each router's metadata and force refreshes on each shard for the given namespace and/or
|
||||
|
@ -70,6 +70,13 @@
|
||||
stmtId: NumberInt(0),
|
||||
startTransaction: true,
|
||||
autocommit: false,
|
||||
// Because ordered writes are done serially for different shard targets and abort early
|
||||
// on first error, this can leave the transaction on the other shards open.
|
||||
// To ensure this router implicitly aborts the transaction on all participants (so
|
||||
// that the next test case does not encounter an open transaction), make this
|
||||
// router do an *unordered* write that touches all the same participants as the
|
||||
// first router touched.
|
||||
ordered: false,
|
||||
}),
|
||||
50911);
|
||||
|
||||
|
@ -53,6 +53,9 @@ MONGO_FAIL_POINT_DEFINE(participantReturnNetworkErrorForCommitAfterExecutingComm
|
||||
MONGO_FAIL_POINT_DEFINE(hangBeforeCommitingTxn);
|
||||
MONGO_FAIL_POINT_DEFINE(hangBeforeAbortingTxn);
|
||||
MONGO_FAIL_POINT_DEFINE(skipCommitTxnCheckPrepareMajorityCommitted);
|
||||
// TODO SERVER-39704: Remove this fail point once the router can safely retry within a transaction
|
||||
// on stale version and snapshot errors.
|
||||
MONGO_FAIL_POINT_DEFINE(dontRemoveTxnCoordinatorOnAbort);
|
||||
|
||||
class CmdCommitTxn : public BasicCommand {
|
||||
public:
|
||||
@ -194,6 +197,13 @@ public:
|
||||
CurOpFailpointHelpers::waitWhileFailPointEnabled(
|
||||
&hangBeforeAbortingTxn, opCtx, "hangBeforeAbortingTxn");
|
||||
|
||||
if (!MONGO_FAIL_POINT(dontRemoveTxnCoordinatorOnAbort) &&
|
||||
(ShardingState::get(opCtx)->canAcceptShardedCommands().isOK() ||
|
||||
serverGlobalParams.clusterRole == ClusterRole::ConfigServer)) {
|
||||
TransactionCoordinatorService::get(opCtx)->cancelIfCommitNotYetStarted(
|
||||
opCtx, *opCtx->getLogicalSessionId(), *opCtx->getTxnNumber());
|
||||
}
|
||||
|
||||
txnParticipant.abortActiveTransaction(opCtx);
|
||||
|
||||
if (MONGO_FAIL_POINT(participantReturnNetworkErrorForAbortAfterExecutingAbortLogic)) {
|
||||
|
Loading…
Reference in New Issue
Block a user