From 792eaed783453a5f840112919fc0adb628961d24 Mon Sep 17 00:00:00 2001 From: Tommaso Tocci Date: Mon, 14 Feb 2022 22:25:55 +0000 Subject: SERVER-63607 Ensure cursor_valid_after_shard_stepdown.js test leaves eligible primaries --- jstests/sharding/cursor_valid_after_shard_stepdown.js | 13 +++++-------- src/mongo/shell/replsettest.js | 12 ++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/jstests/sharding/cursor_valid_after_shard_stepdown.js b/jstests/sharding/cursor_valid_after_shard_stepdown.js index 2c393091205..7da55c8b378 100644 --- a/jstests/sharding/cursor_valid_after_shard_stepdown.js +++ b/jstests/sharding/cursor_valid_after_shard_stepdown.js @@ -1,16 +1,9 @@ - -// Checking UUID consistency involves talking to the shard primary, but by the end of this test, the -// shard does not have a primary. -TestData.skipCheckingUUIDsConsistentAcrossCluster = true; -TestData.skipCheckOrphans = true; - (function() { 'use strict'; var st = new ShardingTest({shards: 1, rs: {nodes: 2}}); assert.commandWorked(st.s0.adminCommand({enablesharding: 'TestDB'})); -st.ensurePrimaryShard('TestDB', st.shard0.shardName); assert.commandWorked(st.s0.adminCommand({shardcollection: 'TestDB.TestColl', key: {x: 1}})); var db = st.s0.getDB('TestDB'); @@ -23,13 +16,17 @@ assert.commandWorked(coll.insert({x: 2, value: 'Test value 2'})); // Establish a cursor on the primary (by not using secondaryOk read) var findCursor = assert.commandWorked(db.runCommand({find: 'TestColl', batchSize: 1})).cursor; +const primary = st.rs0.getPrimary(); + // Stepdown the primary of the shard and ensure that that cursor can still be read -assert.commandWorked(st.rs0.getPrimary().adminCommand({replSetStepDown: 60, force: 1})); +st.rs0.freeze(primary); var getMoreCursor = assert.commandWorked(db.runCommand({getMore: findCursor.id, collection: 'TestColl'})).cursor; assert.eq(0, getMoreCursor.id); assert.eq(2, getMoreCursor.nextBatch[0].x); +st.rs0.unfreeze(primary); + st.stop(); })(); diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 307aa3c1271..6379f2c81b3 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -2965,6 +2965,18 @@ var ReplSetTest = function(opts) { }, `Failed to run replSetFreeze cmd on ${node.host}`); })); + /** + * Unfreeze a particular node or nodes. + * + * @param node is a single node or list of nodes, by id or conn + */ + this.unfreeze = _nodeParamToSingleNode(_nodeParamToConn(function(node) { + // Ensure node is authenticated. + asCluster(node, () => { + assert.commandWorked(node.adminCommand({replSetFreeze: 0})); + }); + })); + this.stopPrimary = function(signal, opts) { var primary = this.getPrimary(); var primary_id = this.getNodeId(primary); -- cgit v1.2.1