summaryrefslogtreecommitdiff
path: root/jstests/sharding/resharding_read_from_secondary.js
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2021-02-24 15:08:40 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-24 16:41:46 +0000
commit6ca44ce30689b3fe93d3afe75f07c70a0fdc3d8d (patch)
treea84afaf9fbebe581a7af6d103e58ea974cc366a2 /jstests/sharding/resharding_read_from_secondary.js
parentfdfc0daa5e3c46ac7a2b6e08d98528b161217467 (diff)
downloadmongo-6ca44ce30689b3fe93d3afe75f07c70a0fdc3d8d.tar.gz
SERVER-54513 Add kAwaitingFetchTimestamp to resharding recipient states.
Also changes the RecoverRefreshThread to insert the donor and recipient state documents rather than the primary-only service Instance itself.
Diffstat (limited to 'jstests/sharding/resharding_read_from_secondary.js')
-rw-r--r--jstests/sharding/resharding_read_from_secondary.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/jstests/sharding/resharding_read_from_secondary.js b/jstests/sharding/resharding_read_from_secondary.js
new file mode 100644
index 00000000000..1d13f76f483
--- /dev/null
+++ b/jstests/sharding/resharding_read_from_secondary.js
@@ -0,0 +1,60 @@
+/**
+ * Tests that replica set shard secondaries don't attempt to create primary-only service Instances
+ * or insert state documents for resharding.
+ *
+ * @tags: [
+ * requires_fcv_49,
+ * requires_find_command,
+ * uses_atclustertime,
+ * ]
+ */
+(function() {
+"use strict";
+
+load("jstests/libs/discover_topology.js");
+load("jstests/libs/fail_point_util.js");
+load("jstests/sharding/libs/resharding_test_fixture.js");
+
+const reshardingTest = new ReshardingTest();
+
+reshardingTest.setup();
+
+const donorShardNames = reshardingTest.donorShardNames;
+const sourceCollection = reshardingTest.createShardedCollection({
+ ns: "reshardingDb.coll",
+ shardKeyPattern: {oldKey: 1},
+ chunks: [{min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]}],
+});
+
+function triggerShardVersionRefreshOnSecondary(collection) {
+ // The shard version refresh would have failed and prevented the secondary from being read from
+ // if it had attempted to create a primary-only service Instance or insert a state document for
+ // resharding.
+ assert.commandWorked(mongos.adminCommand({flushRouterConfig: collection.getFullName()}));
+ collection.find().readPref("secondary").readConcern("local").itcount();
+}
+
+const mongos = sourceCollection.getMongo();
+const topology = DiscoverTopology.findConnectedNodes(mongos);
+const configPrimary = new Mongo(topology.configsvr.primary);
+const fp = configureFailPoint(configPrimary, "reshardingPauseCoordinatorBeforeCloning");
+
+const recipientShardNames = reshardingTest.recipientShardNames;
+reshardingTest.withReshardingInBackground( //
+ {
+ newShardKeyPattern: {newKey: 1},
+ newChunks: [{min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]}],
+ },
+ (tempNs) => {
+ fp.wait();
+
+ triggerShardVersionRefreshOnSecondary(sourceCollection);
+
+ const tempColl = mongos.getCollection(tempNs);
+ triggerShardVersionRefreshOnSecondary(tempColl);
+
+ fp.off();
+ });
+
+reshardingTest.teardown();
+})();