summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorAlex Taskov <alex.taskov@mongodb.com>2020-03-12 14:36:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-12 18:58:49 +0000
commit4e329f262b5c083068700930177d2eb003241273 (patch)
treeff47ec8bcd93dfa8f4834848e059037ee941d2d8 /jstests
parent682ef0452245f0964b9024d00eca0ee8bd1725a1 (diff)
downloadmongo-4e329f262b5c083068700930177d2eb003241273.tar.gz
SERVER-46440 Routing info should be reloaded before retry of creating session collection index on stale config error
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/configsvr_retries_createindex_on_stale_config.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/jstests/sharding/configsvr_retries_createindex_on_stale_config.js b/jstests/sharding/configsvr_retries_createindex_on_stale_config.js
new file mode 100644
index 00000000000..b8d98b4a142
--- /dev/null
+++ b/jstests/sharding/configsvr_retries_createindex_on_stale_config.js
@@ -0,0 +1,40 @@
+/*
+ * Verifies creating the logical sessions collection TTL index retries on stale version errors.
+ */
+
+(function() {
+"use strict";
+
+load('jstests/libs/sessions_collection.js');
+load("jstests/sharding/libs/shard_versioning_util.js");
+
+let st = new ShardingTest({shards: 2});
+
+// Validate the initial state.
+validateSessionsCollection(st.shard0, true, true);
+validateSessionsCollection(st.shard1, false, false);
+validateSessionsCollection(st.configRS.getPrimary(), false, false);
+
+// Drop the TTL index on shard0.
+assert.commandWorked(st.shard0.getDB("config").system.sessions.dropIndex({lastUse: 1}));
+
+// Validate that index has been dropped.
+validateSessionsCollection(st.shard0, true, false);
+validateSessionsCollection(st.shard1, false, false);
+
+// Move the only chunk in the logical sessions collection from shard0 to shard1 with refresh
+// suppressed.
+ShardVersioningUtil.moveChunkNotRefreshRecipient(
+ st.s, "config.system.sessions", st.shard0, st.shard1, {_id: MinKey});
+
+// Refresh session cache.
+assert.commandWorked(
+ st.configRS.getPrimary().getDB("config").runCommand({refreshLogicalSessionCacheNow: 1}));
+
+// Verify that the refresh recreated the index only on the shard that owns the logical sessions
+// collection chunk despite that shard being stale.
+validateSessionsCollection(st.shard0, true, false);
+validateSessionsCollection(st.shard1, true, true);
+
+st.stop();
+})(); \ No newline at end of file