1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
const kSnapshotErrors =
[ErrorCodes.SnapshotTooOld, ErrorCodes.SnapshotUnavailable, ErrorCodes.StaleChunkHistory];
function setFailCommandOnShards(st, mode, commands, code, numShards) {
for (let i = 0; i < numShards; i++) {
const shardConn = st["rs" + i].getPrimary();
assert.commandWorked(shardConn.adminCommand({
configureFailPoint: "failCommand",
mode: mode,
data: {errorCode: code, failCommands: commands}
}));
}
}
function unsetFailCommandOnEachShard(st, numShards) {
for (let i = 0; i < numShards; i++) {
const shardConn = st["rs" + i].getPrimary();
assert.commandWorked(
shardConn.adminCommand({configureFailPoint: "failCommand", mode: "off"}));
}
}
function assertNoSuchTransactionOnAllShards(st, lsid, txnNumber) {
st._rs.forEach(function(rs) {
assertNoSuchTransactionOnConn(rs.test.getPrimary(), lsid, txnNumber);
});
}
function assertNoSuchTransactionOnConn(conn, lsid, txnNumber) {
assert.commandFailedWithCode(conn.getDB("foo").runCommand({
find: "bar",
lsid: lsid,
txnNumber: NumberLong(txnNumber),
autocommit: false,
}),
ErrorCodes.NoSuchTransaction,
"expected there to be no active transaction on shard, lsid: " +
tojson(lsid) + ", txnNumber: " + tojson(txnNumber) +
", connection: " + tojson(conn));
}
|