diff options
author | Luis Osta <luis.osta@mongodb.com> | 2022-01-10 21:38:05 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-10 21:52:44 +0000 |
commit | e46858249a8449e9589bbb926ad367d092d71acc (patch) | |
tree | 285d4994163c5de9eef3b6d5c9b16a2d5090d3e3 | |
parent | 92d90550053426a32c156618cb03cbc7d4c2bedf (diff) | |
download | mongo-e46858249a8449e9589bbb926ad367d092d71acc.tar.gz |
SERVER-60685 Add v4.2 compatibility to test
-rw-r--r-- | jstests/sharding/cancel_coordinate_txn_commit_with_tickets_exhausted.js | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/jstests/sharding/cancel_coordinate_txn_commit_with_tickets_exhausted.js b/jstests/sharding/cancel_coordinate_txn_commit_with_tickets_exhausted.js index f88f1293849..1e8d5251a0d 100644 --- a/jstests/sharding/cancel_coordinate_txn_commit_with_tickets_exhausted.js +++ b/jstests/sharding/cancel_coordinate_txn_commit_with_tickets_exhausted.js @@ -52,6 +52,10 @@ CreateShardedCollectionUtil.shardCollectionWithChunks(sourceCollection, {key: 1} {min: {key: 0}, max: {key: MaxKey}, shard: st.shard1.shardName}, ]); +const isTxnCoordinatorShardLatest = MongoRunner.areBinVersionsTheSame( + MongoRunner.getBinVersionFor("latest"), + MongoRunner.getBinVersionFor(txnCoordinator.fullOptions.binVersion)); + const removeOperationThreads = Array.from({length: kNumWriteTickets}).map(() => { return new Thread(function removeOperation(host, dbName, collName, insertLatch) { const conn = new Mongo(host); @@ -98,8 +102,9 @@ const transactionThread = new Thread( }, () => `Timed out waiting for the remove operations: ${tojson(currentOp())}`); // After here all of the WiredTiger write tickets should be taken. - assert.commandFailedWithCode(session.commitTransaction_forTesting(), - ErrorCodes.NoSuchTransaction); + assert.commandFailedWithCode( + session.commitTransaction_forTesting(), + [ErrorCodes.NoSuchTransaction, ErrorCodes.TransactionCoordinatorReachedAbortDecision]); }, st.s.host, dbName, @@ -112,22 +117,29 @@ transactionThread.start(); removeOperationThreads.forEach(thread => thread.start()); -let twoPhaseCommitCoordinatorServerStatus; -assert.soon( - () => { - twoPhaseCommitCoordinatorServerStatus = - txnCoordinator.getDB(dbName).serverStatus().twoPhaseCommitCoordinator; - const {deletingCoordinatorDoc, waitingForDecisionAcks, writingDecision} = - twoPhaseCommitCoordinatorServerStatus.currentInSteps; - return deletingCoordinatorDoc.toNumber() === 1 || waitingForDecisionAcks.toNumber() === 1 || - writingDecision.toNumber() === 1; - }, - () => `Failed to find 1 total transactions in a state past kWaitingForVotes: ${ - tojson(twoPhaseCommitCoordinatorServerStatus)}`); - -hangWithLockDuringBatchRemoveFp.off(); +// if transaction coordinator is v4.4 then it will get blocked due to the NoSuchTransaction error +if (isTxnCoordinatorShardLatest) { + let twoPhaseCommitCoordinatorServerStatus; + assert.soon( + () => { + twoPhaseCommitCoordinatorServerStatus = + txnCoordinator.getDB(dbName).serverStatus().twoPhaseCommitCoordinator; + const {deletingCoordinatorDoc, waitingForDecisionAcks, writingDecision} = + twoPhaseCommitCoordinatorServerStatus.currentInSteps; + return deletingCoordinatorDoc.toNumber() === 1 || + waitingForDecisionAcks.toNumber() === 1 || writingDecision.toNumber() === 1; + }, + () => `Failed to find 1 total transactions in a state past kWaitingForVotes: ${ + tojson(twoPhaseCommitCoordinatorServerStatus)}`); + + hangWithLockDuringBatchRemoveFp.off(); + + transactionThread.join(); +} else { + transactionThread.join(); + hangWithLockDuringBatchRemoveFp.off(); +} -transactionThread.join(); removeOperationThreads.forEach((thread) => { thread.join(); }); |