Skip to content

Commit ed4709c

Browse files
SERVER-40496 Include namespace in configureFailpoint commands in transactions_snapshot_errors_subsequent_statements.js and transactions_writes_not_retryable.js
1 parent f69bdec commit ed4709c

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

jstests/sharding/libs/sharded_transactions_helpers.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,29 @@ function getCoordinatorFailpoints() {
4242
return coordinatorFailpointDataArr.map(failpoint => Object.assign({}, failpoint));
4343
}
4444

45-
function setFailCommandOnShards(st, mode, commands, code, numShards) {
45+
function setFailCommandOnShards(st, mode, commands, code, numShards, ns) {
4646
for (let i = 0; i < numShards; i++) {
4747
const shardConn = st["rs" + i].getPrimary();
4848
// Sharding tests require failInternalCommands: true, since the mongos appears to mongod to
4949
// be an internal client.
50-
assert.commandWorked(shardConn.adminCommand({
51-
configureFailPoint: "failCommand",
52-
mode: mode,
53-
data: {errorCode: code, failCommands: commands, failInternalCommands: true}
54-
}));
50+
if (ns) {
51+
assert.commandWorked(shardConn.adminCommand({
52+
configureFailPoint: "failCommand",
53+
mode: mode,
54+
data: {
55+
namespace: ns,
56+
errorCode: code,
57+
failCommands: commands,
58+
failInternalCommands: true
59+
}
60+
}));
61+
} else {
62+
assert.commandWorked(shardConn.adminCommand({
63+
configureFailPoint: "failCommand",
64+
mode: mode,
65+
data: {errorCode: code, failCommands: commands, failInternalCommands: true}
66+
}));
67+
}
5568
}
5669
}
5770

jstests/sharding/transactions_snapshot_errors_subsequent_statements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function runTest(st, collName, errorCode, isSharded) {
5959
assert.commandWorked(sessionDB.runCommand({find: collName, filter: {_id: 15}}));
6060

6161
// Verify the command must fail on a snapshot error from a subsequent statement.
62-
setFailCommandOnShards(st, {times: 1}, [commandName], errorCode, 1);
62+
setFailCommandOnShards(st, {times: 1}, [commandName], errorCode, 1, ns);
6363
const res = assert.commandFailedWithCode(sessionDB.runCommand(commandBody), errorCode);
6464
assert.eq(res.errorLabels, ["TransientTransactionError"]);
6565

jstests/sharding/transactions_writes_not_retryable.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ function runTest(st, session, sessionDB, writeCmdName, writeCmd, isSharded) {
2020
assert.commandWorked(st.rs0.getPrimary().adminCommand({
2121
configureFailPoint: "failCommand",
2222
mode: {times: 1},
23-
data: {errorCode: retryableError, failCommands: [writeCmdName], failInternalCommands: true}
23+
data: {
24+
namespace: ns,
25+
errorCode: retryableError,
26+
failCommands: [writeCmdName],
27+
failInternalCommands: true
28+
}
2429
}));
2530

2631
session.startTransaction();
@@ -36,7 +41,12 @@ function runTest(st, session, sessionDB, writeCmdName, writeCmd, isSharded) {
3641
assert.commandWorked(st.rs0.getPrimary().adminCommand({
3742
configureFailPoint: "failCommand",
3843
mode: {times: 1},
39-
data: {closeConnection: true, failCommands: [writeCmdName], failInternalCommands: true}
44+
data: {
45+
namespace: ns,
46+
closeConnection: true,
47+
failCommands: [writeCmdName],
48+
failInternalCommands: true
49+
}
4050
}));
4151

4252
session.startTransaction();

0 commit comments

Comments
 (0)