From b28fa79726fc26276c5cb2eba6bdc44c9c664c03 Mon Sep 17 00:00:00 2001 From: Jordi Serra Torrens Date: Mon, 27 Nov 2023 17:22:33 +0000 Subject: [PATCH] Repro SERVER-82353-b --- jstests/noPassthrough/repro-82353-b.js | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 jstests/noPassthrough/repro-82353-b.js diff --git a/jstests/noPassthrough/repro-82353-b.js b/jstests/noPassthrough/repro-82353-b.js new file mode 100644 index 00000000000..aba2d5c77f8 --- /dev/null +++ b/jstests/noPassthrough/repro-82353-b.js @@ -0,0 +1,41 @@ +(function() { +'use strict'; +const dbName1 = 'test'; +const dbName2 = 'test2'; +const collName1 = 'foo'; +const collName2 = 'foo'; + +const st = new ShardingTest({mongos: 1, shards: 2}); + +function runTest(readConcernLevel) { + st.getDB(dbName1).dropDatabase(); + st.getDB(dbName2).dropDatabase(); + st.adminCommand({enableSharding: dbName1, primaryShard: st.shard0.shardName}); + st.adminCommand({enableSharding: dbName2, primaryShard: st.shard1.shardName}); + + const coll1 = st.getDB(dbName1)[collName1]; + coll1.insert({x: 1, c: 0}); + + const coll2 = st.getDB(dbName2)[collName2]; + coll2.insert({x: 2, c: 0}); + + // Start a multi-document transaction. Execute one statement that will target shard0. + let session = st.s.startSession(); + session.startTransaction({readConcern: {level: readConcernLevel}}); + assert.eq(1, session.getDatabase(dbName1)[collName1].find().itcount()); + + // Run movePrimary to move dbName2 from shard1 to shard0. + assert.commandWorked(st.s.adminCommand({movePrimary: dbName2, to: st.shard0.shardName})); + + // Make sure the router has fresh routing info to avoid causing the transaction to fail due to StaleConfig. + assert.eq(1, coll2.find().itcount()); + + // Execute a second statement, now on dbName2. + assert.eq(1, session.getDatabase(dbName2)[collName2].find().itcount()); +} + +runTest('majority'); +runTest('snapshot'); + +st.stop(); +})(); -- 2.34.1