diff options
author | Rachita Dhawan <rachita.dhawan@gmail.com> | 2022-05-04 19:10:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-17 15:48:13 +0000 |
commit | ce47119ff1a1ab79f18235f1f42eeef39da6f20c (patch) | |
tree | dd34fbdfb6a65fe2378fa7166654c0893ad8db49 /jstests | |
parent | 387db2d0f7b26b4ae6efdf46854e60f12f93d4d2 (diff) | |
download | mongo-ce47119ff1a1ab79f18235f1f42eeef39da6f20c.tar.gz |
SERVER-62175 Mongos fails to attach RetryableWrite Error Label For Command Interrupted In _parseCommandr6.0.0-rc6
(cherry picked from commit 38e4a5516d614a2bd1f3c3afde97c19068fd1441)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/mongos_insert_fails_with_shutdown.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/jstests/sharding/mongos_insert_fails_with_shutdown.js b/jstests/sharding/mongos_insert_fails_with_shutdown.js new file mode 100644 index 00000000000..df02f6f54e6 --- /dev/null +++ b/jstests/sharding/mongos_insert_fails_with_shutdown.js @@ -0,0 +1,59 @@ +/** +@tags: [multiversion_incompatible] +*/ + +// Don't check for UUID index consistency,orphans and routine table across the cluster at the end, +// since the test shuts down a mongos +TestData.skipCheckingUUIDsConsistentAcrossCluster = true; +TestData.skipCheckingIndexesConsistentAcrossCluster = true; +TestData.skipCheckOrphans = true; +TestData.skipCheckRoutingTableConsistency = true; +(function() { +"use strict"; + +load("jstests/libs/fail_point_util.js"); +load('jstests/libs/parallelTester.js'); +load("jstests/libs/retryable_writes_util.js"); +const st = new ShardingTest({ + mongos: 1, + config: 1, + shards: 2, +}); +const dbName = "test"; +const collName = "mycoll"; +const fpData = { + "cmdName": "insert", + "ns": dbName + '.' + collName +}; +const hangBeforeCheckInterruptFailPoint = + configureFailPoint(st.s, "hangBeforeCheckingMongosShutdownInterrupt", fpData); + +const insertThread = new Thread(function insertDoc(host, dbName, collName) { + var lsid = UUID(); + const conn = new Mongo(host); + const retrySession = conn.startSession({retryWrites: true}); + const retrySessionDB = retrySession.getDatabase(dbName); + + try { + var res = assert.commandWorked(retrySessionDB.runCommand({ + insert: 'mycoll', + documents: [{x: 0}, {x: 1}], + ordered: true, + lsid: {id: lsid}, + txnNumber: NumberLong(1) + })); + + } catch (e) { + assert.eq(e.errorLabels, ["RetryableWriteError"], e); + } + retrySession.endSession(); +}, st.s.host, dbName, collName); + +insertThread.start(); +hangBeforeCheckInterruptFailPoint.wait(); + +st.stopMongos(0); +insertThread.join(); + +st.stop(); +})(); |