From fcbab1f087d191200f6edf292873a30b12c9e527 Mon Sep 17 00:00:00 2001 From: Jordi Serra Torrens Date: Thu, 25 Jan 2024 15:00:45 +0000 Subject: [PATCH] Repro 85583 --- jstests/sharding/repro-85583.js | 38 +++++++++++++++++++++++++ src/mongo/db/commands/run_aggregate.cpp | 4 +++ 2 files changed, 42 insertions(+) create mode 100644 jstests/sharding/repro-85583.js diff --git a/jstests/sharding/repro-85583.js b/jstests/sharding/repro-85583.js new file mode 100644 index 00000000000..4ea16ced101 --- /dev/null +++ b/jstests/sharding/repro-85583.js @@ -0,0 +1,38 @@ +import {configureFailPoint} from "jstests/libs/fail_point_util.js"; +import {funWithArgs} from "jstests/libs/parallel_shell_helpers.js"; + +(function() { +'use strict'; + +const dbName = 'test'; +const collName = 'foo'; +const ns = dbName + '.' + collName; + +const st = new ShardingTest({mongos: 1, shards: 2}); +const db = st.s.getDB(dbName); +let coll = db[collName]; + +st.adminCommand({enableSharding: dbName, primaryShard: st.shard0.shardName}); +assert.commandWorked(db.createCollection(collName, {timeseries: {timeField: 't'}})); + +const fp = configureFailPoint(st.rs0.getPrimary(), 'hangAfterResolvingView'); + +const awaitReadTs = + startParallelShell(funWithArgs(function(dbName) { + assert.commandWorked(db.getSiblingDB(dbName)['foo'].find().itcount()); + }, dbName), st.s.port); + +jsTest.log("--DEBUG-- Waiting to hit FP"); +fp.wait(); +jsTest.log("--DEBUG-- Hit FP"); + +assert.commandWorked(db.adminCommand({movePrimary: dbName, to: st.shard1.shardName})); + +jsTest.log("--DEBUG-- Moved primary"); +fp.off(); + +awaitReadTs(); +jsTest.log("--DEBUG-- awaitReadTs done"); + +st.stop(); +})(); diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index f4ee6ef5189..e09e7df6a94 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -182,6 +182,7 @@ namespace { MONGO_FAIL_POINT_DEFINE(hangAfterCreatingAggregationPlan); MONGO_FAIL_POINT_DEFINE(hangAfterAcquiringCollectionCatalog); +MONGO_FAIL_POINT_DEFINE(hangAfterResolvingView); /** * If a pipeline is empty (assuming that a $cursor stage hasn't been created yet), it could mean @@ -1021,6 +1022,9 @@ Status runAggregateOnView(OperationContext* opCtx, resolvedView, request); } else { + + hangAfterResolvingView.pauseWhileSet(); + // Sharding-aware operation. sharding::router::CollectionRouter router(opCtx->getServiceContext(), resolvedView.getNamespace()); -- 2.34.1