From 4605de0e64aa4e57487e620f91e5de52615a1941 Mon Sep 17 00:00:00 2001 From: Jamie Heppenstall Date: Thu, 1 Aug 2019 15:29:16 -0400 Subject: SERVER-40496 Include namespace in configureFailpoint commands in transactions_snapshot_errors_subsequent_statements.js and transactions_writes_not_retryable.js (cherry picked from commit ed4709c4b0d3c34bd085fdfe4f1b54557956080f) --- .../sharding/libs/sharded_transactions_helpers.js | 25 ++++++++++++++++------ ...ctions_snapshot_errors_subsequent_statements.js | 2 +- .../sharding/transactions_writes_not_retryable.js | 14 ++++++++++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/jstests/sharding/libs/sharded_transactions_helpers.js b/jstests/sharding/libs/sharded_transactions_helpers.js index dc49b839e30..a25eef6e7f8 100644 --- a/jstests/sharding/libs/sharded_transactions_helpers.js +++ b/jstests/sharding/libs/sharded_transactions_helpers.js @@ -42,16 +42,29 @@ function getCoordinatorFailpoints() { return coordinatorFailpointDataArr.map(failpoint => Object.assign({}, failpoint)); } -function setFailCommandOnShards(st, mode, commands, code, numShards) { +function setFailCommandOnShards(st, mode, commands, code, numShards, ns) { for (let i = 0; i < numShards; i++) { const shardConn = st["rs" + i].getPrimary(); // Sharding tests require failInternalCommands: true, since the mongos appears to mongod to // be an internal client. - assert.commandWorked(shardConn.adminCommand({ - configureFailPoint: "failCommand", - mode: mode, - data: {errorCode: code, failCommands: commands, failInternalCommands: true} - })); + if (ns) { + assert.commandWorked(shardConn.adminCommand({ + configureFailPoint: "failCommand", + mode: mode, + data: { + namespace: ns, + errorCode: code, + failCommands: commands, + failInternalCommands: true + } + })); + } else { + assert.commandWorked(shardConn.adminCommand({ + configureFailPoint: "failCommand", + mode: mode, + data: {errorCode: code, failCommands: commands, failInternalCommands: true} + })); + } } } diff --git a/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js b/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js index e83ef670708..d3ac5f6e15c 100644 --- a/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js +++ b/jstests/sharding/transactions_snapshot_errors_subsequent_statements.js @@ -59,7 +59,7 @@ function runTest(st, collName, errorCode, isSharded) { assert.commandWorked(sessionDB.runCommand({find: collName, filter: {_id: 15}})); // Verify the command must fail on a snapshot error from a subsequent statement. - setFailCommandOnShards(st, {times: 1}, [commandName], errorCode, 1); + setFailCommandOnShards(st, {times: 1}, [commandName], errorCode, 1, ns); const res = assert.commandFailedWithCode(sessionDB.runCommand(commandBody), errorCode); assert.eq(res.errorLabels, ["TransientTransactionError"]); diff --git a/jstests/sharding/transactions_writes_not_retryable.js b/jstests/sharding/transactions_writes_not_retryable.js index e6782394ec7..99dc2155469 100644 --- a/jstests/sharding/transactions_writes_not_retryable.js +++ b/jstests/sharding/transactions_writes_not_retryable.js @@ -20,7 +20,12 @@ function runTest(st, session, sessionDB, writeCmdName, writeCmd, isSharded) { assert.commandWorked(st.rs0.getPrimary().adminCommand({ configureFailPoint: "failCommand", mode: {times: 1}, - data: {errorCode: retryableError, failCommands: [writeCmdName], failInternalCommands: true} + data: { + namespace: ns, + errorCode: retryableError, + failCommands: [writeCmdName], + failInternalCommands: true + } })); session.startTransaction(); @@ -36,7 +41,12 @@ function runTest(st, session, sessionDB, writeCmdName, writeCmd, isSharded) { assert.commandWorked(st.rs0.getPrimary().adminCommand({ configureFailPoint: "failCommand", mode: {times: 1}, - data: {closeConnection: true, failCommands: [writeCmdName], failInternalCommands: true} + data: { + namespace: ns, + closeConnection: true, + failCommands: [writeCmdName], + failInternalCommands: true + } })); session.startTransaction(); -- cgit v1.2.1