summaryrefslogtreecommitdiff
path: root/jstests/sharding/retryable_writes.js
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2020-02-18 16:19:33 +0000
committerevergreen <evergreen@mongodb.com>2020-02-18 16:19:33 +0000
commiteb284b042c71edf0eac445d3ceb79f7fdeabc5d1 (patch)
tree3edc885bd11497dd8cca1073f72df3e4909ecd94 /jstests/sharding/retryable_writes.js
parentd9a68d2c084bfed60527aa9aa29e2a843b97e9c2 (diff)
downloadmongo-eb284b042c71edf0eac445d3ceb79f7fdeabc5d1.tar.gz
SERVER-43889 Distinguish between retryable write and transaction when failing a command
Diffstat (limited to 'jstests/sharding/retryable_writes.js')
-rw-r--r--jstests/sharding/retryable_writes.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/jstests/sharding/retryable_writes.js b/jstests/sharding/retryable_writes.js
index 9da8f40effa..c361052fce2 100644
--- a/jstests/sharding/retryable_writes.js
+++ b/jstests/sharding/retryable_writes.js
@@ -400,6 +400,30 @@ function runFailpointTests(mainConn, priConn) {
assert.eq(1, collContents[1].y);
}
+function runRetryableWriteErrorTest(mainConn) {
+ // Test TransactionTooOld error message on retryable writes
+ const lsid = UUID();
+ const testDb = mainConn.getDB('TestDB');
+
+ assert.commandWorked(testDb.runCommand({
+ insert: 'user',
+ documents: [{x: 1}],
+ ordered: true,
+ lsid: {id: lsid},
+ txnNumber: NumberLong(2)
+ }));
+ const writeResult = testDb.runCommand({
+ update: 'user',
+ updates: [{q: {x: 1}, u: {$inc: {x: 1}}}],
+ ordered: true,
+ lsid: {id: lsid},
+ txnNumber: NumberLong(1)
+ });
+ assert.commandFailedWithCode(writeResult, ErrorCodes.TransactionTooOld);
+ assert(writeResult.errmsg.includes("Retryable write with txnNumber 1 is prohibited"),
+ writeResult);
+}
+
function runMultiTests(mainConn) {
// Test the behavior of retryable writes with multi=true / limit=0
var lsid = {id: UUID()};
@@ -514,6 +538,7 @@ var priConn = replTest.getPrimary();
runTests(priConn, priConn);
runFailpointTests(priConn, priConn);
+runRetryableWriteErrorTest(priConn);
runMultiTests(priConn);
runInvalidTests(priConn);