diff --git a/jstests/noPassthrough/repro.js b/jstests/noPassthrough/repro.js new file mode 100644 index 00000000000..568b77a989a --- /dev/null +++ b/jstests/noPassthrough/repro.js @@ -0,0 +1,54 @@ +import {configureFailPoint} from "jstests/libs/fail_point_util.js"; +import {funWithArgs} from "jstests/libs/parallel_shell_helpers.js"; +import {ShardingTest} from "jstests/libs/shardingtest.js"; +import {restartServerReplication, stopServerReplication} from "jstests/libs/write_concern_util.js"; + +const st = new ShardingTest({ + shards: 1, + rs: {nodes: 1}, + configShard: true, +}); + +function dropSessionsCollectionManually(st) { + let collDoc = + st.s.getDB("config").getCollection("collections").findOne({_id: "config.system.sessions"}); + if (collDoc == undefined) { + return; + } + let uuid = collDoc.uuid; + assert.commandWorked(st.s.getDB("config").getCollection("collections").deleteOne({ + _id: "config.system.sessions" + })); + assert.commandWorked(st.s.getDB("config").getCollection("chunks").deleteMany({uuid: uuid})); + st.configRS.getPrimary().getDB("config").getCollection("system.sessions").drop(); +} + +let failpoint = configureFailPoint(st.rs0.getPrimary(), "pauseBeforeCreatingCollection"); + +dropSessionsCollectionManually(st); + +jsTest.log("Start running logical sessions refresh but pause it"); +const awaitResult = startParallelShell( + funWithArgs(function(ns) { + assert.commandWorked(db.adminCommand({refreshLogicalSessionCacheNow: 1})); + }, "test.foo"), st.configRS.getPrimary().port); + +jsTest.log("Wait to hit failpoint"); +failpoint.wait(); + +jsTest.log("Add another node to the shard replica set"); +let newNode = st.rs0.add({"configsvr": '', rsConfig: {priority: 0, votes: 0}}); +st.rs0.reInitiate(); +st.rs0.awaitSecondaryNodes(); + +jsTest.log("Stop replication so that the primary can't reach the new secondary"); +stopServerReplication(newNode); + +jsTest.log("Release the shard collection and see if it works"); +failpoint.off(); +awaitResult(); + +jsTest.log("Done"); +restartServerReplication(newNode); + +st.stop(); diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp index 0112bd5c6a3..9bdb362a1f1 100644 --- a/src/mongo/db/s/create_collection_coordinator.cpp +++ b/src/mongo/db/s/create_collection_coordinator.cpp @@ -147,6 +147,7 @@ #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kSharding MONGO_FAIL_POINT_DEFINE(failAtCommitCreateCollectionCoordinator); MONGO_FAIL_POINT_DEFINE(hangBeforeCommitOnShardingCatalog); +MONGO_FAIL_POINT_DEFINE(pauseBeforeCreatingCollectionLocally); namespace mongo { @@ -1221,6 +1222,7 @@ boost::optional createCollectionAndIndexes( const ShardId& dataShard) { LOGV2_DEBUG( 5277903, 2, "Create collection createCollectionAndIndexes", logAttrs(translatedNss)); + pauseBeforeCreatingCollectionLocally.pauseWhileSet(); // TODO (SERVER-77915): Remove once 8.0 becomes last LTS. boost::optional diff --git a/src/mongo/db/s/sessions_collection_config_server.cpp b/src/mongo/db/s/sessions_collection_config_server.cpp index cf5975ae893..10a8cc0b58b 100644 --- a/src/mongo/db/s/sessions_collection_config_server.cpp +++ b/src/mongo/db/s/sessions_collection_config_server.cpp @@ -78,7 +78,12 @@ namespace mongo { +namespace { +MONGO_FAIL_POINT_DEFINE(pauseBeforeCreatingCollection); +} + void SessionsCollectionConfigServer::_shardCollectionIfNeeded(OperationContext* opCtx) { + pauseBeforeCreatingCollection.pauseWhileSet(); // First, check if the collection is already sharded. try { checkSessionsCollectionExists(opCtx);