diff options
author | Randolph Tan <randolph@10gen.com> | 2020-08-06 18:41:30 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-16 14:56:03 +0000 |
commit | 1786a10c7278a9242566ec5647687fa95bf68f12 (patch) | |
tree | ddb7bc5e6c4b6a08a78d0a9ec5e3f18c1cf70b4f | |
parent | 673ec7c2e11cbdeb41b440351e7634b5f39fa745 (diff) | |
download | mongo-1786a10c7278a9242566ec5647687fa95bf68f12.tar.gz |
SERVER-48573 txn_two_phase_commit_killop.js should handle clients with no opCtx
(cherry picked from commit 47af7f4c26237857843aaa61728280d6de9fbe4d)
-rw-r--r-- | jstests/sharding/txn_two_phase_commit_killop.js | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/jstests/sharding/txn_two_phase_commit_killop.js b/jstests/sharding/txn_two_phase_commit_killop.js index 66a2a7895ba..de777534a97 100644 --- a/jstests/sharding/txn_two_phase_commit_killop.js +++ b/jstests/sharding/txn_two_phase_commit_killop.js @@ -121,19 +121,32 @@ const testCommitProtocol = function(shouldCommit, failpointData) { failpointData.numTimesShouldBeHit); jsTest.log("Going to find coordinator opCtx ids"); - let coordinatorOps = coordinator.getDB("admin") - .aggregate([ - {$currentOp: {'allUsers': true, 'idleConnections': true}}, - {$match: {desc: "TransactionCoordinator"}} - ]) - .toArray(); + let coordinatorOpsToKill = []; + assert.soon(() => { + coordinatorOpsToKill = coordinator.getDB("admin") + .aggregate([ + {$currentOp: {'allUsers': true, 'idleConnections': true}}, + {$match: {desc: "TransactionCoordinator"}} + ]) + .toArray(); + + for (let x = 0; x < coordinatorOpsToKill.length; x++) { + if (!coordinatorOpsToKill[x].opid) { + print("Retrying currentOp because op doesn't have opId: " + + tojson(coordinatorOpsToKill[x])); + return false; + } + } + + return true; + }, 'timed out trying to fetch coordinator ops', undefined /* timeout */, 1000 /* interval */); // Use "greater than or equal to" since, for failpoints that pause the coordinator while // it's sending prepare or sending the decision, there might be one additional thread that's // doing the "send" to the local participant (or that thread might have already completed). - assert.gte(coordinatorOps.length, failpointData.numTimesShouldBeHit); + assert.gte(coordinatorOpsToKill.length, failpointData.numTimesShouldBeHit); - coordinatorOps.forEach(function(coordinatorOp) { + coordinatorOpsToKill.forEach(function(coordinatorOp) { coordinator.getDB("admin").killOp(coordinatorOp.opid); }); assert.commandWorked(coordinator.adminCommand({ |