From ba844b4e81c3914b8a7017bd2a8c5ac4231c72ff Mon Sep 17 00:00:00 2001 From: Matthew Russotto Date: Mon, 6 May 2019 14:50:06 -0400 Subject: SERVER-40996 abortTransaction in cleanup_txns.js does not handle different errors from different shards --- jstests/concurrency/fsm_workload_helpers/cleanup_txns.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'jstests/concurrency') diff --git a/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js b/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js index 9fb5a3f9a8d..34a9bc0dab7 100644 --- a/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js +++ b/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js @@ -26,8 +26,19 @@ function abortTransaction(sessionAwareDB, txnNumber) { autocommit: false }; const res = rawDB.adminCommand(abortCmd); - return assert.commandWorkedOrFailedWithCode( - res, abortErrorCodes, () => `cmd: ${tojson(abortCmd)}`); + if (res.hasOwnProperty("raw")) { + // For sharded commands, we may get mismatched errors in which case there will be + // no top-level code. Instead, check each code from the shards. + for (let shardname in res.raw) { + let shardres = res.raw[shardname]; + assert.commandWorkedOrFailedWithCode( + shardres, abortErrorCodes, () => `cmd: ${tojson(abortCmd)}`); + } + return res; + } else { + return assert.commandWorkedOrFailedWithCode( + res, abortErrorCodes, () => `cmd: ${tojson(abortCmd)}`); + } } /** -- cgit v1.2.1