summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@gmail.com>2020-05-15 16:13:30 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-28 20:53:41 +0000
commitc28892ddb597e2875cda52dcf35810b7395c7dc1 (patch)
treea9e49e0e5f46f6a6ecd1e4b993a97ffccb3b0e8c
parent8f61b845bb0c760772be20ac1ce517816da9366c (diff)
downloadmongo-c28892ddb597e2875cda52dcf35810b7395c7dc1.tar.gz
SERVER-47209 Account for rollback in change_streams_update_lookup_shard_metadata_missing.js
(cherry picked from commit 8cb02c375ad128bca9bad7edcc29a8c55fbd9269)
-rw-r--r--jstests/multiVersion/libs/multi_cluster.js10
-rw-r--r--jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js37
2 files changed, 23 insertions, 24 deletions
diff --git a/jstests/multiVersion/libs/multi_cluster.js b/jstests/multiVersion/libs/multi_cluster.js
index 5244fbe17a8..3cbba1f801e 100644
--- a/jstests/multiVersion/libs/multi_cluster.js
+++ b/jstests/multiVersion/libs/multi_cluster.js
@@ -2,9 +2,6 @@
// MultiVersion utility functions for clusters
//
-load('jstests/multiVersion/libs/multi_rs.js'); // For upgradeSet.
-load('jstests/replsets/rslib.js'); // For awaitRSClientHosts.
-
/**
* Restarts the specified binaries in options with the specified binVersion.
* Note: this does not perform any upgrade operations.
@@ -16,8 +13,14 @@ load('jstests/replsets/rslib.js'); // For awaitRSClientHosts.
* upgradeShards: <bool>, // defaults to true
* upgradeConfigs: <bool>, // defaults to true
* upgradeMongos: <bool>, // defaults to true
+ * waitUntilStable: <bool>, // defaults to false since it provides a more realistic
+ * approximation of real-world upgrade behaviour, even though
+ * certain tests will likely want a stable cluster after upgrading.
* }
*/
+load("jstests/multiVersion/libs/multi_rs.js"); // Used by upgradeSet.
+load("jstests/replsets/rslib.js"); // For awaitRSClientHosts.
+
ShardingTest.prototype.upgradeCluster = function(binVersion, options) {
options = options || {};
if (options.upgradeShards == undefined)
@@ -105,7 +108,6 @@ ShardingTest.prototype.waitUntilStable = function() {
rs.test.awaitSecondaryNodes();
shardPrimaries.push(rs.test.getPrimary());
}
-
// Wait for the ReplicaSetMonitor on mongoS and each shard to reflect the state of all shards.
for (let client of [...this._mongos, ...shardPrimaries]) {
awaitRSClientHosts(client, shardPrimaries, {ok: true, ismaster: true});
diff --git a/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js b/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js
index f2ff1c27564..562242f07e8 100644
--- a/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js
+++ b/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js
@@ -7,6 +7,8 @@
(function() {
"use strict";
+load("jstests/multiVersion/libs/multi_cluster.js"); // For ShardingTest.waitUntilStable.
+
// The UUID consistency check can hit NotMasterNoSlaveOk when it attempts to obtain a list of
// collections from the shard Primaries through mongoS at the end of this test.
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
@@ -15,12 +17,12 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
const st = new ShardingTest({
shards: 2,
mongos: 1,
- rs: {nodes: 3, setParameter: {writePeriodicNoops: true, periodicNoopIntervalSecs: 1}}
+ rs: {nodes: 3, setParameter: {writePeriodicNoops: true, periodicNoopIntervalSecs: 5}}
});
-const mongosDB = st.s.getDB(jsTestName());
-const mongosColl = mongosDB.test;
-const shard0 = st.rs0;
+let mongosDB = st.s.getDB(jsTestName());
+let mongosColl = mongosDB.test;
+let shard0 = st.rs0;
// Enable sharding on the the test database and ensure that the primary is shard0.
assert.commandWorked(mongosDB.adminCommand({enableSharding: mongosDB.getName()}));
@@ -38,26 +40,21 @@ assert.soon(() => csCursor.hasNext());
const resumeToken = csCursor.next()._id;
-// get any secondary
-const newPrimary = st.rs0.getSecondary();
-let shards = st.s.getDB('config').shards.find().toArray();
+// Obtain a reference to any secondary.
+const newPrimary = shard0.getSecondary();
// Step up one of the Secondaries, which will not have any sharding metadata loaded.
-st.rs0.stepUpNoAwaitReplication(newPrimary);
-
-// make sure the mongos refreshes it's connections to the shard
-let primary = {};
-do {
- let connPoolStats = st.s0.adminCommand({connPoolStats: 1});
- primary = connPoolStats.replicaSets[shards[0]._id].hosts.find((host) => {
- return host.ismaster;
- }) ||
- {};
-} while (newPrimary.host !== primary.addr);
+shard0.stepUp(newPrimary);
+
+// Make sure the mongoS and both shards sees shard0's new primary.
+st.waitUntilStable();
+
+// Refresh our reference to the test collection.
+mongosColl = st.s.getDB(mongosDB.getName())[mongosColl.getName()];
// Do a {multi:true} update. This will scatter to all shards and update the document on shard0.
-// Because no metadata is loaded, the shard will return a StaleShardVersion and fetch it,
-// the operation will be retried
+// Because no metadata is loaded, the shard will return a StaleShardVersion and fetch it, and
+// the operation will be retried until it completes successfully.
assert.soonNoExcept(
() => assert.commandWorked(mongosColl.update({_id: 0}, {$set: {updated: true}}, false, true)));