summaryrefslogtreecommitdiff
path: root/jstests/sharding/mongos_quiesce_mode.js
diff options
context:
space:
mode:
authorPavi Vetriselvan <pvselvan@umich.edu>2020-05-14 09:07:42 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-21 04:49:46 +0000
commit0ab12830d07bc60523d4a21eb216ba4ab70a2be2 (patch)
tree6859137c7648be803bef85ffe319d2b399b643af /jstests/sharding/mongos_quiesce_mode.js
parentac55d9ad9fcf1a7d55e811ad351540f700a5bcc2 (diff)
downloadmongo-0ab12830d07bc60523d4a21eb216ba4ab70a2be2.tar.gz
SERVER-47018 Attach topology version to shutdown errors while in quiesce mode
Diffstat (limited to 'jstests/sharding/mongos_quiesce_mode.js')
-rw-r--r--jstests/sharding/mongos_quiesce_mode.js41
1 files changed, 38 insertions, 3 deletions
diff --git a/jstests/sharding/mongos_quiesce_mode.js b/jstests/sharding/mongos_quiesce_mode.js
index e9255a9580c..f87e21f47a5 100644
--- a/jstests/sharding/mongos_quiesce_mode.js
+++ b/jstests/sharding/mongos_quiesce_mode.js
@@ -21,13 +21,21 @@ const collName = "coll";
const mongosDB = mongos.getDB(dbName);
assert.commandWorked(mongosDB.coll.insert([{_id: 0}, {_id: 1}, {_id: 2}, {_id: 3}]));
+function checkTopologyVersion(res, topologyVersionField) {
+ assert(res.hasOwnProperty("topologyVersion"), res);
+ assert.eq(res.topologyVersion.counter, topologyVersionField.counter + 1);
+}
+
function runAwaitableIsMaster(topologyVersionField) {
- assert.commandFailedWithCode(db.runCommand({
+ let res = assert.commandFailedWithCode(db.runCommand({
isMaster: 1,
topologyVersion: topologyVersionField,
maxAwaitTimeMS: 99999999,
}),
- ErrorCodes.ShutdownInProgress);
+ ErrorCodes.ShutdownInProgress);
+
+ assert(res.hasOwnProperty("topologyVersion"), res);
+ assert.eq(res.topologyVersion.counter, topologyVersionField.counter + 1);
}
function runFind() {
@@ -74,6 +82,11 @@ quiesceModeFailPoint.wait();
jsTestLog("The waiting isMaster returns a ShutdownInProgress error.");
isMaster();
+jsTestLog("New isMaster command returns a ShutdownInProgress error.");
+checkTopologyVersion(
+ assert.commandFailedWithCode(mongos.adminCommand({isMaster: 1}), ErrorCodes.ShutdownInProgress),
+ topologyVersionField);
+
// Test operation behavior during quiesce mode.
jsTestLog("The running read operation is allowed to finish.");
findCmdFailPoint.off();
@@ -93,8 +106,30 @@ assert.eq(5, mongosDB.coll.find().itcount());
jsTestLog("New writes are allowed.");
assert.commandWorked(mongosDB.coll.insert({_id: 5}));
-// Restart mongos
+jsTestLog("Let shutdown progress to start killing operations.");
+let pauseWhileKillingOperationsFailPoint =
+ configureFailPoint(mongos, "pauseWhileKillingOperationsAtShutdown");
+
+// Exit quiesce mode so we can hit the pauseWhileKillingOperationsFailPoint failpoint.
quiesceModeFailPoint.off();
+
+// This throws because the configureFailPoint command is killed by the shutdown.
+try {
+ pauseWhileKillingOperationsFailPoint.wait();
+} catch (e) {
+ if (e.code === ErrorCodes.InterruptedAtShutdown) {
+ jsTestLog(
+ "Ignoring InterruptedAtShutdown error because configureFailPoint is killed by shutdown");
+ } else {
+ throw e;
+ }
+}
+
+jsTestLog("Operations fail with a shutdown error and append the topologyVersion.");
+checkTopologyVersion(assert.commandFailedWithCode(mongosDB.runCommand({find: collName}),
+ ErrorCodes.InterruptedAtShutdown),
+ topologyVersionField);
+// Restart mongos.
st.restartMongos(0);
st.stop();