SERVER-96971 Prevent ReplSetTest.waitForState from returning stale data for SECONDARY state (#29585)

GitOrigin-RevId: 9d38b94afbd94ff5dffa63b7ec487ea54fa4a98d
This commit is contained in:
Moustafa Maher 2024-12-05 10:46:06 -08:00 committed by MongoDB Bot
parent e008eafe51
commit 6849b3ff14
111 changed files with 149 additions and 156 deletions

View File

@ -98,7 +98,7 @@ Object.keys(initialMechStats).forEach(function(mech) {
const newNode = rst.add({});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
rst.awaitReplication();
rst.stop(newNode);

View File

@ -106,7 +106,7 @@ export function testPreservingRecordIdsDuringInitialSync(
});
replTest.reInitiate();
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
replTest.awaitReplication();
validateShowRecordIdReplicatesAcrossNodes([primary, initialSyncNode], dbName, collName);
@ -157,7 +157,7 @@ export function testPreservingRecordIdsDuringInitialSync(
jsTestLog("Resume initial sync.");
assert.commandWorked(
initialSyncNode.adminCommand({configureFailPoint: afterCloningFP, mode: "off"}));
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
replTest.awaitReplication();
validateShowRecordIdReplicatesAcrossNodes([primary, initialSyncNode], dbName, collName);
@ -208,7 +208,7 @@ export function testPreservingRecordIdsDuringInitialSync(
jsTestLog("Resume initial sync.");
assert.commandWorked(
initialSyncNode.adminCommand({configureFailPoint: beforeCloningFP, mode: "off"}));
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
replTest.awaitReplication();
validateShowRecordIdReplicatesAcrossNodes([primary, initialSyncNode], dbName, collName);
@ -237,7 +237,7 @@ export function testPreservingRecordIdsDuringInitialSync(
}
});
replTest.reInitiate();
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
replTest.awaitReplication();
validateShowRecordIdReplicatesAcrossNodes([primary, initialSyncNode], dbName, collName);

View File

@ -107,7 +107,7 @@ export class ReplSetTest {
* Wait for a rs indicator to go to a particular state or states.
*
* @private
* @param node is a single node or list of nodes, by id or conn
* @param node is a single node, by id or conn
* @param states is a single state or list of states
* @param ind is the indicator specified
* @param timeout how long to wait for the state to be reached
@ -502,7 +502,7 @@ export class ReplSetTest {
assert.soonNoExcept(() => {
awaitingSecondaries = [];
// Reload who the current secondaries are
this.getPrimary(timeout);
_callHello(this);
var secondariesToCheck = secondaries || this._secondaries;
var len = secondariesToCheck.length;
@ -3047,16 +3047,20 @@ export class ReplSetTest {
/**
* Wait for a state indicator to go to a particular state or states.
*
* Note that this waits for the state as indicated by the primary node. If you want to wait for
* a node to actually reach SECONDARY state, as reported by itself, use awaitSecondaryNodes
* instead.
* Note that this waits for the state as indicated by the primary node, if there is one. If not,
* it will use the first live node.
*
* @param node is a single node or list of nodes, by id or conn
* Cannot be used to wait for a secondary state alone. To wait for a secondary state, use the
* function 'awaitSecondaryNodes' instead.
*
* @param node is a single node, by id or conn
* @param state is a single state or list of states
* @param timeout how long to wait for the state to be reached
* @param reconnectNode indicates that we should reconnect to a node that stepped down
*/
waitForState(node, state, timeout, reconnectNode) {
assert(state != ReplSetTest.State.SECONDARY,
"To wait for a secondary state, use the function 'awaitSecondaryNodes' instead.");
this._waitForIndicator(node, "state", state, timeout, reconnectNode);
}

View File

@ -51,7 +51,7 @@ function runTest(downgradeVersion) {
rst.stop(latestSecondary);
// The primary should step down, since it can no longer see a majority of the replica set.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
restartServerReplication(downgradeSecondary);
rst.stopSet();

View File

@ -50,7 +50,7 @@ function runReplicaSet() {
jsTestLog("Restarting the primary.");
rst.restart(primaryId, {}, true /* wait */);
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
fcvDoc = primaryAdminDB.system.version.findOne({_id: 'featureCompatibilityVersion'});
jsTestLog(`Old primary's version after restarting: ${tojson(fcvDoc)}`);

View File

@ -93,11 +93,9 @@ ReplSetTest.prototype.upgradePrimary = function(primary, options, user, pwd) {
authNode(primary);
let oldPrimary = this.stepdown(primary);
this.waitForState(oldPrimary, ReplSetTest.State.SECONDARY, undefined, authNode);
this.awaitSecondaryNodes(null, [oldPrimary]);
// waitForState() runs the logout command via asCluster() on either the current primary or the
// first node in the replica set so we re-authenticate on all connections before calling
// awaitNodesAgreeOnPrimary().
// we need to re-authenticate on all connections before calling awaitNodesAgreeOnPrimary().
for (const node of this.nodes) {
const connStatus =
assert.commandWorked(node.adminCommand({connectionStatus: 1, showPrivileges: true}));

View File

@ -42,7 +42,7 @@ checkLog.contains(primary,
"enabled. Blocking until fail point is disabled");
assert.commandWorked(testDB.adminCommand({replSetStepDown: 60, force: true}));
replSet.waitForState(primary, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [primary]);
assert.commandWorked(primary.adminCommand({configureFailPoint: failpoint, mode: "off"}));
awaitShell();

View File

@ -62,7 +62,7 @@ assert.commandWorked(primary.adminCommand({
// Step down the primary.
assert.commandWorked(testDB.adminCommand({replSetStepDown: 10, secondaryCatchUpPeriodSecs: 10}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
// Resume the abort.
assert.commandWorked(

View File

@ -60,7 +60,7 @@ const createIdx = IndexBuildTest.startIndexBuild(primary, "test.anotherColl", {a
assert.commandWorked(secondary.adminCommand(
{configureFailPoint: "initialSyncHangBeforeCopyingDatabases", mode: "off"}));
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
createIdx();
rst.stopSet();

View File

@ -73,6 +73,6 @@ secondary = rst.restart(
SIGKILL);
// Wait for initial sync to finish.
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -144,7 +144,7 @@ assert.eq(indexBulkBuilderSection.memUsage, 0, tojson(indexBulkBuilderSection));
const newNode =
replSet.add({setParameter: {maxIndexBuildMemoryUsageMegabytes: maxMemUsageMegabytes}});
replSet.reInitiate();
replSet.waitForState(newNode, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [newNode]);
replSet.awaitReplication();
let newNodeTestDB = newNode.getDB(testDB.getName());
let newNodeColl = newNodeTestDB.getCollection(coll.getName());

View File

@ -50,7 +50,7 @@ awaitIndexBuild();
checkLog.containsJson(primary, 4612300);
assert.commandWorked(testDB.adminCommand({replSetStepDown: 60, force: true}));
replSet.waitForState(primary, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [primary]);
assert.commandWorked(primary.adminCommand({configureFailPoint: failpoint, mode: "off"}));

View File

@ -88,7 +88,7 @@ for (let nodeIdx = 0; nodeIdx < 2; ++nodeIdx) {
{
jsTestLog("Starting as a replica set. Both indexes should exist. Node: " + nodeIdentity);
let conn = rst.start(nodeIdx, {startClean: false}, true);
rst.waitForState(conn, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [conn]);
conn.setSecondaryOk();
IndexBuildTest.assertIndexes(getColl(conn), 2, ['_id_', 'foo_1']);
rst.stop(nodeIdx);

View File

@ -304,8 +304,7 @@ export const BackupRestoreTest = function(options) {
}
// Wait up to 5 minutes until restarted node is in state secondary.
rst.getSecondaries().forEach(secondary =>
rst.waitForState(secondary, ReplSetTest.State.SECONDARY));
rst.awaitSecondaryNodes();
jsTestLog('Stopping CRUD and FSM clients');
@ -382,7 +381,7 @@ export const BackupRestoreTest = function(options) {
// Wait up to 5 minutes until the new hidden node is in state SECONDARY.
jsTestLog('CRUD and FSM clients stopped. Waiting for hidden node ' + hiddenHost +
' to become SECONDARY');
rst.waitForState(hiddenNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [hiddenNode]);
// Wait for secondaries to finish catching up before shutting down.
jsTestLog(

View File

@ -79,7 +79,7 @@ assertMetricsExist(metricsBefore[db2Name]);
const newNode = replSet.add({setParameter: setParams});
replSet.reInitiate();
replSet.waitForState(newNode, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [newNode]);
replSet.awaitReplication();
// Ensure that the initial syncing node has not collected any metrics.

View File

@ -84,6 +84,6 @@ assert.commandWorked(
secondary.adminCommand({configureFailPoint: "hangBeforeClonerStage", mode: 'off'}));
jsTestLog("Waiting for initial sync to complete successfully.");
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
replTest.stopSet();

View File

@ -38,9 +38,7 @@ function stepDownPrimary(rst) {
// We wait for the primary to transition to the SECONDARY state to ensure we're waiting
// until after the parallel shell has started the replSetStepDown command.
const reconnectNode = false;
rst.waitForState(directConn, ReplSetTest.State.SECONDARY, null, reconnectNode);
rst.awaitSecondaryNodes(null, [directConn]);
return awaitShell;
}

View File

@ -23,8 +23,7 @@ function stepDownPrimary(rst) {
// until after the parallel shell has started the replSetStepDown command and the server is
// paused at the failpoint. Do not attempt to reconnect to the node, since the node will be
// holding the global X lock at the failpoint.
const reconnectNode = false;
rst.waitForState(directConn, ReplSetTest.State.SECONDARY, null, reconnectNode);
rst.awaitSecondaryNodes(null, [directConn]);
return awaitShell;
}

View File

@ -70,7 +70,7 @@ function testStepdown(stepdownFunc) {
// It should be possible to step down the primary without hanging.
stepdownFunc(rst);
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
// Kill the cursor.
assert.commandWorked(sessionDB.runCommand({killCursors: collName, cursors: [cursorId]}));

View File

@ -42,7 +42,7 @@ function runTest(host, rst, waitForPrimary) {
var primary = rst.getPrimary();
var secondary = rst.getSecondary();
assert.commandWorked(primary.getDB("admin").runCommand({replSetStepDown: 60, force: true}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
if (waitForPrimary) {
rst.waitForState(secondary, ReplSetTest.State.PRIMARY);
}

View File

@ -57,7 +57,7 @@ const stepDownThread = startParallelShell(() => {
assert.commandWorked(db.adminCommand({"replSetStepDown": 60, force: true}));
}, s0primary.port);
st.rs0.waitForState(s0primary, ReplSetTest.State.SECONDARY);
st.rs0.awaitSecondaryNodes(null, [s0primary]);
fp.off();

View File

@ -155,7 +155,7 @@ checkServerStatus(configPrimaryConn, configSecondaryConn, connsWithoutIndexConsi
// appropriate test variables.
st.configRS.stepUp(configSecondaryConn);
st.configRS.waitForState(configSecondaryConn, ReplSetTest.State.PRIMARY);
st.configRS.waitForState(configPrimaryConn, ReplSetTest.State.SECONDARY);
st.configRS.awaitSecondaryNodes(null, [configPrimaryConn]);
st.configRS.awaitNodesAgreeOnPrimary();
configSecondaryConn = configPrimaryConn;

View File

@ -68,6 +68,6 @@ assert.commandWorked(db.createCollection(collName, {timeseries: {timeField: "tim
assert.commandWorked(secondary.adminCommand(
{configureFailPoint: "initialSyncHangBeforeCopyingDatabases", mode: "off"}));
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -47,7 +47,7 @@ assert.eq(1, getExtendedRangeCount(primary));
assert.eq(1, getExtendedRangeCount(secondary));
rst.restart(primary, {skipValidation: true});
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
assert.eq(1, primaryDB.standard.count());
assert.eq(1, primaryDB.extended.count());

View File

@ -40,7 +40,7 @@ assert.commandWorked(secondary.adminCommand({fsync: 1}));
// Restart the secondary and check for the startup warning in the logs.
secondary = rst.restart(secondary);
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
// Wait for "Found an existing TTL index with NaN 'expireAfterSeconds' in the catalog" log message.
checkLog.containsJson(secondary, 6852200, {

View File

@ -73,7 +73,7 @@ function test(expireAfterSecondsVal) {
// sync.
const newNode = rst.add({rsConfig: {votes: 0, priority: 0}});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
rst.awaitReplication();
let newNodeTestDB = newNode.getDB(db.getName());
let newNodeColl = newNodeTestDB.getCollection(coll.getName());

View File

@ -104,7 +104,7 @@ function createIndexWithoutExpireAfterSecondsValidation(coll, indexName, expireA
const newNode = rst.add({rsConfig: {votes: 0, priority: 0}});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
rst.awaitReplication();
let newNodeTestDB = newNode.getDB(dbName);
let newNodeColl = newNodeTestDB.getCollection(collName);

View File

@ -30,7 +30,7 @@ function testAddWithInitialSync(secondariesDown) {
const majorityDown = secondariesDown > 1;
if (majorityDown) {
// Wait for the set to become unhealthy.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
}
// Atlas always adds nodes with 0 votes and priority
const newNode = rst.add({rsConfig: {votes: 0, priority: 0}});
@ -44,7 +44,7 @@ function testAddWithInitialSync(secondariesDown) {
{replSetReconfig: config, maxTimeMS: ReplSetTest.kDefaultTimeoutMS, force: majorityDown}));
jsTestLog("Waiting for node to sync.");
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
jsTestLog("Reconfiguring added node to have votes");
config = rst.getReplSetConfigFromNode(primary.nodeId);
@ -82,7 +82,7 @@ function testReplaceWithInitialSync(secondariesDown) {
disconnectSecondaries(rst, secondariesDown);
if (majorityDown) {
// Wait for the set to become unhealthy.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
}
jsTestLog("Stopping node for replacement of data");

View File

@ -67,7 +67,7 @@ function testAddWithSnapshot(secondariesDown) {
const useForce = secondariesDown > 1;
if (useForce) {
// Wait for the set to become unhealthy.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
}
// Atlas always adds nodes with 0 votes and priority
const newNode =
@ -82,7 +82,7 @@ function testAddWithSnapshot(secondariesDown) {
{replSetReconfig: config, maxTimeMS: ReplSetTest.kDefaultTimeoutMS, force: useForce}));
jsTestLog("Waiting for node to sync.");
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
jsTestLog("Reconfiguring added node to have votes");
config = rst.getReplSetConfigFromNode(primary.nodeId);
@ -126,7 +126,7 @@ function testReplaceWithSnapshot(node, secondariesDown) {
disconnectSecondaries(secondariesDown);
if (useForce) {
// Wait for the set to become unhealthy.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
}
jsTestLog("Stopping node for replacement of data");
rst.stop(node, undefined, undefined, {forRestart: true});

View File

@ -22,7 +22,7 @@ var testInvalidAuthStates = function(replSetTest) {
jsTestLog("shut down 2, 0 becomes a secondary.");
replSetTest.stop(2);
replSetTest.waitForState(replSetTest.nodes[0], ReplSetTest.State.SECONDARY);
replSetTest.awaitSecondaryNodes(null, [replSetTest.nodes[0]]);
};
var name = "rs_auth2";

View File

@ -18,7 +18,7 @@ assert.commandWorked(conn.getDB('admin').foo.insert({a: 1}, {writeConcern: {w: N
// Make sure there is no primary
rs.stop(0);
rs.stop(1);
rs.waitForState(nodes[2], ReplSetTest.State.SECONDARY);
rs.awaitSecondaryNodes(null, [nodes[2]]);
// Make sure you can still authenticate a replset connection with no primary
var conn2 = new Mongo(rs.getURL());

View File

@ -38,7 +38,7 @@ const secondary = rst.add({
}
});
rst.reInitiate();
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Checking that the primary has initiated the removal of 'newlyAdded'");
hangBeforeNewlyAddedRemovalFP.wait();

View File

@ -102,6 +102,6 @@ replSet.waitForState(2, ReplSetTest.State.PRIMARY, replSet.timeoutMS);
jsTestLog('node 2 performed priority takeover and is now primary');
// Wait until the old primary steps down so the connections won't be closed during stopSet().
replSet.waitForState(0, ReplSetTest.State.SECONDARY, replSet.timeoutMS);
replSet.awaitSecondaryNodes(replSet.timeoutMS, [nodes[0]]);
replSet.stopSet();

View File

@ -66,7 +66,7 @@ verifyServerStatusElectionReasonCounterChange(
initialPrimaryStatus.electionMetrics, newPrimaryStatus.electionMetrics, "catchUpTakeover", 1);
// Wait until the old primary steps down.
replSet.waitForState(2, ReplSetTest.State.SECONDARY, replSet.timeoutMS);
replSet.awaitSecondaryNodes(replSet.timeoutMS, [nodes[2]]);
// Check that the 'numCatchUpsFailedWithNewTerm' field has been incremented in serverStatus, and
// that none of the other reasons for catchup concluding has been incremented.

View File

@ -62,7 +62,7 @@ assert.commandWorked(initialSyncNode.adminCommand(
// Wait until the initial sync process is complete and the new node becomes a fully
// functioning secondary.
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
// Verify that pre-images were not written during the logical initial sync. At this point the
// pre-image collections in the nodes of the replica set are out of sync.

View File

@ -212,7 +212,7 @@ for (const [collectionName, collectionOptions] of [
// Wait until the initial sync process is complete and the new node becomes a fully
// functioning secondary.
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
// Verify that pre-images were not written during the logical initial sync.
let preImageDocuments = getPreImages(initialSyncNode);

View File

@ -43,7 +43,7 @@ replTest.awaitReplication();
jsTestLog("Testing that changestream survives stepdown between find and getmore");
// Step down.
assert.commandWorked(primaryDb.adminCommand({replSetStepDown: 60, force: true}));
replTest.waitForState(primary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [primary]);
// Receive the first change event. This tests stepdown between find and getmore.
res = assert.commandWorked(
@ -68,7 +68,7 @@ assert.eq(changes[0]["operationType"], "insert");
jsTestLog("Testing that changestream survives stepdown between two getmores");
// Step down again.
assert.commandWorked(primaryDb.adminCommand({replSetStepDown: 60, force: true}));
replTest.waitForState(primary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [primary]);
// Get the next one. This tests that changestreams survives a step down between getmores.
res = assert.commandWorked(

View File

@ -193,6 +193,6 @@ assert.commandWorked(
secondaryDb.adminCommand({configureFailPoint: "hangBeforeStartingOplogFetcher", mode: "off"}));
jsTestLog("Waiting for initial sync to complete.");
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -92,7 +92,7 @@ assert.commandWorked(secondary.adminCommand(
{configureFailPoint: "initialSyncHangBeforeCopyingDatabases", mode: "off"}));
// Wait for the secondary to complete initial sync.
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Initial sync completed");

View File

@ -49,7 +49,7 @@ jsTestLog("Allowing primary to initiate the 'newlyAdded' field removal");
let hangDuringAutomaticReconfigFP = configureFailPoint(primaryDb, "hangDuringAutomaticReconfig");
assert.commandWorked(
secondary.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
hangDuringAutomaticReconfigFP.wait();

View File

@ -53,7 +53,7 @@ jsTest.log("Node B steps up in term 2 and performs a write, which is not replica
// E:
stopServerReplication([nodeA, nodeC, nodeD]);
assert.commandWorked(nodeB.adminCommand({replSetStepUp: 1}));
rst.waitForState(nodeA, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [nodeA]);
assert.eq(nodeB, rst.getPrimary());
assert.commandWorked(nodeB.getDB(dbName)[collName].insert({term: 2}));
rst.waitForConfigReplication(nodeB, [nodeA, nodeB, nodeC, nodeD]);

View File

@ -27,7 +27,7 @@ function testAddWithInitialSync(secondariesDown) {
const majorityDown = secondariesDown > 1;
if (majorityDown) {
// Wait for the set to become unhealthy.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
}
// Add a new, voting node.
const newNode = rst.add({rsConfig: {priority: 0}});
@ -41,7 +41,7 @@ function testAddWithInitialSync(secondariesDown) {
{replSetReconfig: config, maxTimeMS: ReplSetTest.kDefaultTimeoutMS, force: majorityDown}));
jsTestLog("Waiting for node to sync.");
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
// Make sure the set is still consistent after adding the node.
reconnectSecondaries(rst);
@ -69,7 +69,7 @@ function testReplaceWithInitialSync(secondariesDown) {
disconnectSecondaries(rst, secondariesDown);
if (majorityDown) {
// Wait for the set to become unhealthy.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
}
let nodeId = rst.getNodeId(nodeToBeReplaced);
@ -107,7 +107,7 @@ function testReplaceWithInitialSync(secondariesDown) {
{replSetReconfig: config, maxTimeMS: ReplSetTest.kDefaultTimeoutMS, force: majorityDown}));
jsTestLog("Waiting for the replacement node to sync.");
rst.waitForState(replacementNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [replacementNode]);
if (!majorityDown) {
// Make sure we can replicate to it, if the set is otherwise healthy.

View File

@ -155,9 +155,9 @@ assert.commandWorked(
assert.commandWorked(
thirdNewNode.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(firstNewNode, ReplSetTest.State.SECONDARY);
rst.waitForState(secondNewNode, ReplSetTest.State.SECONDARY);
rst.waitForState(thirdNewNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [firstNewNode]);
rst.awaitSecondaryNodes(null, [secondNewNode]);
rst.awaitSecondaryNodes(null, [thirdNewNode]);
jsTestLog("Making sure the set can accept writes with write concerns");
assert.commandWorked(primaryColl.insert({"steady": "state"}, {writeConcern: {w: 4}}));

View File

@ -72,7 +72,7 @@ runDbCheck(
assert.commandWorked(initialSyncNode.adminCommand(
{configureFailPoint: 'initialSyncHangBeforeSplittingControlFlow', mode: 'off'}));
replSet.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [initialSyncNode]);
// Check that the primary logged an error health log entry for each document with missing index key.
checkHealthLog(primaryHealthlog, logQueries.missingIndexKeysQuery, nDocs);

View File

@ -97,7 +97,7 @@ replTest.stop(secondary1);
print("8. Eventually the new node should become a secondary");
print("if initial sync has started, this will cause it to fail and sleep for 5 minutes");
replTest.waitForState(secondary2, ReplSetTest.State.SECONDARY, 60 * 1000);
replTest.awaitSecondaryNodes(60 * 1000, [secondary2]);
print("9. Bring the secondary back up");
replTest.start(secondary1, {}, true);

View File

@ -99,6 +99,6 @@ assert.commandWorked(secondary.getDB("test").adminCommand(
{configureFailPoint: "hangBeforeStartingOplogFetcher", mode: "off"}));
jsTestLog("Waiting for initial sync to complete.");
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -97,7 +97,7 @@ assert.commandWorked(secondary.adminCommand(
{configureFailPoint: "initialSyncHangDuringCollectionClone", mode: "off"}));
// Wait for the secondary to complete initial sync.
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Initial sync completed");

View File

@ -92,7 +92,7 @@ function finishTest({failPoint, expectedLog, createNew}) {
}
jsTestLog("Waiting for initial sync to complete.");
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
let res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(0, res.initialSyncStatus.failedInitialSyncAttempts);
@ -162,7 +162,7 @@ runDropTest({
// secondary will be finished with initial sync when the drop happens.
var secondary2 = replTest.add({rsConfig: {priority: 0}});
replTest.reInitiate();
replTest.waitForState(secondary2, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary2]);
jsTestLog("[5] Testing committed drop between getMore calls.");
runDropTest({

View File

@ -77,11 +77,11 @@ function finishTest(
configureFailPoint(primaryAdmin, failPoint, {}, "off");
jsTestLog("Waiting for initial sync to complete.");
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
// Wait until the primary transitioned to SECONDARY state.
joinStepDownThread();
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
jsTestLog("Validating initial sync data.");
let res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));

View File

@ -137,7 +137,7 @@ assert.commandWorked(secondary.adminCommand(
jsTestLog("Initial sync resumed");
// Wait for the secondary to complete initial sync.
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
replTest.awaitReplication();
jsTestLog("Initial sync completed");

View File

@ -98,7 +98,7 @@ replTest.awaitReplication();
jsTestLog("Secondary was restarted");
// Wait for the secondary to complete initial sync.
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Initial sync completed");

View File

@ -65,5 +65,5 @@ assert.commandWorked(secondary.getDB("test").adminCommand(
jsTestLog("Waiting for initial sync to complete.");
// Wait for initial sync to complete.
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -98,7 +98,7 @@ function finishTest({failPoint, expectedLog, createNew, renameAcrossDBs}) {
}
jsTestLog("Waiting for initial sync to complete.");
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
let res = assert.commandWorked(secondary.adminCommand({replSetGetStatus: 1}));
assert.eq(0, res.initialSyncStatus.failedInitialSyncAttempts);

View File

@ -130,7 +130,7 @@ jsTestLog("Resuming batch application on the secondary");
dropFailPoint.off();
jsTestLog("Waiting for initial sync to complete");
rst.waitForState(initSyncNode, ReplSetTest.State.SECONDARY); // will time out on error
rst.awaitSecondaryNodes(null, [initSyncNode]); // will time out on error
rst.awaitReplication();
rst.stopSet();

View File

@ -104,7 +104,7 @@ jsTestLog("Failing first initial sync attempt");
assert.commandWorked(secondary.adminCommand(
{configureFailPoint: "failInitialSyncBeforeApplyingBatch", mode: "off"}));
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Initial sync completed");

View File

@ -104,6 +104,6 @@ jsTestLog("Re-adding initial sync node a final time");
config.members[1].host = origHost;
config.version++;
assert.commandWorked(primary.adminCommand({replSetReconfig: config, force: 1}));
rst.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [initialSyncNode]);
rst.stopSet();

View File

@ -93,5 +93,5 @@ jsTestLog("Releasing the final cloner failpoint.");
afterStageFailPoint.off();
jsTestLog("Waiting for initial sync to complete.");
// Wait for initial sync to complete.
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -117,5 +117,5 @@ jsTestLog("Releasing the final cloner failpoint.");
afterStageFailPoint.off();
jsTestLog("Waiting for initial sync to complete.");
// Wait for initial sync to complete.
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
rst.stopSet();

View File

@ -72,7 +72,7 @@ jsTestLog("Disconnecting old primary");
node0.disconnect(node1);
node0.disconnect(node2);
assert.commandWorked(oldPrimary.adminCommand({replSetStepDown: 10 * 60, force: true}));
rst.waitForState(rst.nodes[0], ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [rst.nodes[0]]);
jsTestLog("Electing new primary");
@ -107,7 +107,7 @@ assert.soonNoExcept(function() {
return rbid > lastRBID;
}, "rbid did not update", ReplSetTest.kDefaultTimeoutMS);
rst.waitForState(rst.nodes[0], ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [rst.nodes[0]]);
jsTestLog("Done with test");
rst.stopSet();

View File

@ -77,7 +77,7 @@ assert.commandWorked(
readBlockedOnPrepareConflictThread();
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
// Validate that the read operation got killed during step down.
let replMetrics = assert.commandWorked(primaryAdmin.adminCommand({serverStatus: 1})).metrics.repl;

View File

@ -98,7 +98,7 @@ rst.stepUp(secondary);
waitForSecondaryReadBlockedOnPrepareConflictThread();
rst.waitForState(secondary, ReplSetTest.State.PRIMARY);
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
primary = rst.getPrimary();

View File

@ -42,7 +42,7 @@ let ttlPassesBeforeStepdown = getNumTTLPasses();
// Force a stepdown of the primary.
assert.commandWorked(
primary.getDB("admin").runCommand({replSetStepDown: 60 * 10 /* 10 minutes */, force: true}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
assert.commandWorked(primary.adminCommand({replSetFreeze: 0}));
assert.commandWorked(primary.adminCommand({replSetStepUp: 1}));

View File

@ -71,7 +71,7 @@ for (var i = 0; i < numElections; i++) {
rst.stepUp(secondary);
// Make sure a new primary has been established.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
rst.waitForState(secondary, ReplSetTest.State.PRIMARY);
// Reset election timeout for the old primary.
@ -107,7 +107,7 @@ setLastVoteDoc(node0, term, rst.nodes[0]);
jsTestLog("Restarting node 0 in replica set mode");
node0 = rst.restart(0); // Restart in replSet mode again.
rst.waitForState(node0, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [node0]);
assert.soonNoExcept(function() {
assertCurrentTerm(node0, term);

View File

@ -54,7 +54,7 @@ export function InitialSyncTest(
const primary = replSet.getPrimary();
let secondary = replSet.getSecondary();
replSet.waitForState(secondary, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [secondary]);
/**
* Return an instance of ReplSetTest initialized with a standard two-node replica set running

View File

@ -55,7 +55,7 @@ export var testPrepareFailoverDueToReconfig = function(name, reconfigOnPrimary)
// Run the reconfig command on whichever node the caller targeted.
const reconfigTarget = reconfigOnPrimary ? primary : secondary;
assert.commandWorked(reconfigTarget.adminCommand({replSetReconfig: config, force: true}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
// Wait for the old secondary to become the new primary.
const newPrimary = rst.getPrimary();

View File

@ -87,7 +87,7 @@ assertVoteCount(primary, {
jsTestName("Allowing one of the secondaries to complete initial sync (_id 1, index 2)");
assert.commandWorked(
newNodeTwo.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(newNodeTwo, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNodeTwo]);
jsTestName("Waiting for its 'newlyAdded' to be removed");
waitForNewlyAddedRemovalForNodeToBeCommitted(primary, 2 /* memberIndex */);
@ -113,7 +113,7 @@ assert(configOnDisk.members[1]["newlyAdded"], configOnDisk);
jsTestName("Letting the other secondary node finish initial sync (_id 2, index 1)");
assert.commandWorked(
newNodeOne.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(newNodeOne, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNodeOne]);
jsTestName("Waiting for the second 'newlyAdded' field to be removed.");
waitForNewlyAddedRemovalForNodeToBeCommitted(primary, 1 /* memberIndex */);

View File

@ -79,7 +79,7 @@ assert.commandWorked(
waitForUserReconfig();
jsTestLog("Waiting for 'newlyAdded' field to be removed");
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
waitForNewlyAddedRemovalForNodeToBeCommitted(primary, 1);
assertVoteCount(primary, {
votingMembersCount: 2,

View File

@ -100,7 +100,7 @@ jsTestLog("Allowing member to complete initial sync");
let doNotRemoveNewlyAddedFP = configureFailPoint(primaryDb, "doNotRemoveNewlyAddedOnHeartbeats");
assert.commandWorked(
secondary.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Checking that the 'newlyAdded' field is still set");
assert(isMemberNewlyAdded(primary, 1));

View File

@ -32,7 +32,7 @@ rst.awaitReplication();
jsTestLog("Stepping down with no command in progress. Should not disconnect.");
// If the 'primary' connection is broken on stepdown, this command will fail.
assert.commandWorked(primaryAdmin.adminCommand({replSetStepDown: 60, force: true}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
// If the 'primaryDataConn' connection was broken during stepdown, this command will fail.
assert.commandWorked(primaryDb.adminCommand({ping: 1}));
// Allow the primary to be re-elected, and wait for it.
@ -60,7 +60,7 @@ function runStepDownTest({description, failpoint, operation, errorCode}) {
const waitForShell = startParallelShell(writeCommand, primary.port);
waitForCurOpByFailPointNoNS(primaryAdmin, failpoint);
assert.commandWorked(primaryAdmin.adminCommand({replSetStepDown: 60, force: true}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
assert.commandWorked(primaryAdmin.adminCommand({configureFailPoint: failpoint, mode: "off"}));
try {
waitForShell();

View File

@ -57,7 +57,7 @@ replSet.awaitReplication();
jsTestLog("Taking secondary out of maintenance mode so it will transition back to SECONDARY");
assert.commandWorked(secondary.adminCommand({replSetMaintenance: 0}));
replSet.waitForState(secondary, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Stepping up the secondary");

View File

@ -35,7 +35,7 @@ const awaitStepUp = startParallelShell(() => {
// Wait for secondary to hit the failpoint. Even though the election on secondary has not finished,
// the primary should step down due to seeing a higher term.
voteRequestCompleteFailPoint.wait();
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
jsTestLog("Make the secondary hang after entering quiesce mode.");
let quiesceModeFailPoint = configureFailPoint(secondary, "hangDuringQuiesceMode");

View File

@ -115,7 +115,7 @@ try {
if (res) {
assert.commandWorked(res);
}
rst.waitForState(nodes[0], ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [nodes[0]]);
reconnect(nodes[0]);
// At this point the former primary will attempt to go into rollback, but the

View File

@ -87,7 +87,7 @@ configureFailPoint(primaryAdmin, "waitAfterPinningCursorBeforeGetMoreBatch", {}
// Wait until the primary transitioned to SECONDARY state.
joinStepDownThread();
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
// We don't want to check if we have reached "waitAfterCommandFinishesExecution" fail point
// because we already know that the primary has stepped down successfully. This implies that

View File

@ -81,7 +81,7 @@ assert.soon(() => isConfigCommitted(node1));
node0.reconnect([node1, node2, node3]);
// The newly connected node will receive a heartbeat with a higher term, and
// step down from being primary. The reconfig command issued to this node, C1, will fail.
rst.waitForState(node0, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [node0]);
rst.awaitNodesAgreeOnPrimary(rst.timeoutMS, [node0, node1, node3], node1);
rst.waitForConfigReplication(node1);
assert.eq(C2, rst.getReplSetConfigFromNode());

View File

@ -81,7 +81,7 @@ assert.commandWorked(secondTermPrimary.adminCommand({replSetReconfig: newConfig}
rollbackTest.getTestFixture().waitForConfigReplication(secondTermPrimary);
// Verify the removed node is added back and primary sees its state as SECONDARY.
rollbackTest.getTestFixture().waitForState(rollbackNode, ReplSetTest.State.SECONDARY);
rollbackTest.getTestFixture().awaitSecondaryNodes(null, [rollbackNode]);
// Transition back to steady state.
rollbackTest.transitionToSteadyStateOperations();

View File

@ -50,7 +50,7 @@ const initialSyncNode = replTest.add(
{setParameter: {logComponentVerbosity: tojsononeline({replication: 5, storage: 5})}});
replTest.reInitiate();
replTest.waitForState(initialSyncNode, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [initialSyncNode]);
replTest.awaitReplication();
validateShowRecordIdReplicatesAcrossNodes([primary, initialSyncNode], dbName, collName);

View File

@ -132,7 +132,7 @@ jsTestLog("Waiting for initial sync to complete");
let doNotRemoveNewlyAddedFP = configureFailPoint(primaryDb, "doNotRemoveNewlyAddedOnHeartbeats");
assert.commandWorked(
secondary.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(secondary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary]);
jsTestLog("Checking that the 'newlyAdded' field is still set");
assert(isMemberNewlyAdded(primary, 3));

View File

@ -58,7 +58,7 @@ assertVoteCount(primary, {
jsTestLog("Waiting for initial sync to complete");
assert.commandWorked(
secondary0.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(secondary0, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary0]);
jsTestLog("Checking that 'newlyAdded' field is still not set");
assert(!isMemberNewlyAdded(primary, 1));
@ -125,7 +125,7 @@ assertVoteCount(primary, {
jsTestLog("Waiting for second initial sync to complete");
assert.commandWorked(
secondary1.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(secondary1, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary1]);
jsTestLog("Checking that 'newlyAdded' field was removed");
waitForNewlyAddedRemovalForNodeToBeCommitted(primary, 2);

View File

@ -80,7 +80,7 @@ jsTestLog("Allowing primary to initiate the 'newlyAdded' field removal for the f
let hangDuringAutomaticReconfigFP = configureFailPoint(primaryDb, "hangDuringAutomaticReconfig");
assert.commandWorked(
newNodeOne.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(newNodeOne, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNodeOne]);
hangDuringAutomaticReconfigFP.wait();
@ -123,7 +123,7 @@ assert(configOnDisk.members[1]["newlyAdded"], configOnDisk);
jsTestLog("Letting the other secondary node finish initial sync");
assert.commandWorked(
newNodeTwo.adminCommand({configureFailPoint: "initialSyncHangBeforeFinish", mode: "off"}));
rst.waitForState(newNodeTwo, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNodeTwo]);
jsTestLog("Waiting for the second 'newlyAdded' field to be removed (_id 2, index 1)");
waitForNewlyAddedRemovalForNodeToBeCommitted(primary, 1 /* memberIndex */);

View File

@ -21,7 +21,7 @@ primaryCollection.save({a: 1});
var newNode = replTest.add();
replTest.reInitiate();
replTest.waitForState(replTest.nodes[1], ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [replTest.nodes[1]]);
// Allow documents to propagate to new replica set member.
replTest.awaitReplication();

View File

@ -22,7 +22,7 @@ replTest.awaitNodesAgreeOnPrimary(replTest.timeoutMS, nodes, nodes[2]);
// wait for 1 to not appear to be primary (we are about to make it primary and need a clean slate
// here)
replTest.waitForState(nodes[1], ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [nodes[1]]);
// Wait for election oplog entry to be replicated, to ensure 0 will vote for 1 after stopping 2.
replTest.awaitReplication();

View File

@ -85,7 +85,7 @@ assert.commandWorked(
assert.commandWorked(
rollbackNode.adminCommand({replSetStepDown: ReplSetTest.kForeverSecs, force: true}));
rst.waitForState(rollbackNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [rollbackNode]);
restartServerReplication(syncSource);

View File

@ -51,7 +51,7 @@ rst.awaitLastOpCommitted();
jsTestLog("Step up the secondary");
rst.stepUp(secConn);
assert.eq(secConn, rst.getPrimary());
rst.waitForState(priConn, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [priConn]);
jsTestLog("commitTransaction command is retryable after failover");
@ -84,12 +84,12 @@ assert.commandFailedWithCode(
jsTestLog("Step up the original primary");
rst.stepUp(priConn);
assert.eq(priConn, rst.getPrimary());
rst.waitForState(secConn, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secConn]);
jsTestLog("Step up the original secondary immediately");
rst.stepUp(secConn);
assert.eq(secConn, rst.getPrimary());
rst.waitForState(priConn, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [priConn]);
assert.commandWorked(PrepareHelpers.commitTransaction(secSession, prepareTimestamp2));

View File

@ -78,7 +78,7 @@ jsTestLog({
jsTestLog("Resuming initial sync.");
assert.commandWorked(
node1.adminCommand({configureFailPoint: "initialSyncHangAfterDataCloning", mode: 'off'}));
rst.waitForState(node1, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [node1]);
let initialSyncedNode = rst.getSecondary();
rst.stepUp(initialSyncedNode);

View File

@ -152,7 +152,7 @@ function runTest(crashAfterRollbackTruncation) {
"noReplSet": false,
setParameter: 'failpoint.stopReplProducer=' + tojson({mode: 'alwaysOn'})
});
rst.waitForState(secondary1, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary1]);
secondary1.setSecondaryOk();
// On startup, we expect to see the update persisted in the 'config.transactions' table.
let restoredDoc =
@ -162,7 +162,7 @@ function runTest(crashAfterRollbackTruncation) {
} else {
// Lift the failpoint to let rollback complete and wait for state to change to SECONDARY.
hangAfterTruncate.off();
rst.waitForState(secondary1, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [secondary1]);
}
// Reconnect to secondary1 after it completes its rollback and step it up to be the new primary.

View File

@ -39,7 +39,7 @@ function checkClusterParameterInitialSync(rst) {
// with all data fully replicated to it.
const newNode = rst.add({});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
rst.awaitReplication();
// Check that the new node has the latest cluster parameter values.

View File

@ -132,7 +132,7 @@ jsTest.log("allowing heartbeat stepdown " + secondary.host);
blockHeartbeatStepdownFailPoint.off();
jsTestLog("Checking that node successfully stepped down");
replSet.waitForState(secondary, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [secondary]);
assert(!secondary.adminCommand('hello').isWritablePrimary);
// Now ensure that the node can successfully become primary again.

View File

@ -65,7 +65,7 @@ rst.stepUp(secondary);
jsTestLog("Wait for step up to complete");
// Wait until the primary successfully steps down via heartbeat reconfig.
rst.waitForState(secondary, ReplSetTest.State.PRIMARY);
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
const newPrimary = rst.getPrimary();
jsTestLog("Prepare a transaction on the new primary");

View File

@ -34,7 +34,7 @@ function runTest(downgradeFCV) {
jsTestLog("Stepping down the primary");
assert.commandWorked(primary.adminCommand({replSetStepDown: 10 * 60, force: 1}));
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
rst.awaitNodesAgreeOnPrimary();
primary = rst.getPrimary();

View File

@ -49,7 +49,7 @@ jsTestLog("Stepping down");
assert.commandWorked(primary.getDB('admin').runCommand({replSetStepDown: 30}));
jsTestLog("Waiting for former PRIMARY to become SECONDARY");
replSet.waitForState(primary, ReplSetTest.State.SECONDARY, 30000);
replSet.awaitSecondaryNodes(30000, [primary]);
const newPrimary = replSet.getPrimary();
assert.neq(primary, newPrimary, "SECONDARY did not become PRIMARY");

View File

@ -68,7 +68,7 @@ jsTestLog('Enable replication on the SECONDARY ' + secondary.host);
restartServerReplication(secondary);
jsTestLog("Wait for PRIMARY " + primary.host + " to completely step down.");
replSet.waitForState(primary, ReplSetTest.State.SECONDARY);
replSet.awaitSecondaryNodes(null, [primary]);
var exitCode = stepDowner();
jsTestLog("Wait for SECONDARY " + secondary.host + " to become PRIMARY");

View File

@ -138,7 +138,7 @@ assertStepDownSucceeds(primary);
// Make sure that original primary has transitioned to SECONDARY state
jsTestLog("Wait for PRIMARY " + primary.host + " to completely step down.");
replTest.waitForState(primary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [primary]);
// Disable all fail points for clean shutdown
restartReplSetReplication(replTest);

View File

@ -94,7 +94,7 @@ jsTestLog("Trying to step down primary with 3 nodes out of 5 caught up.");
assertStepDownSucceeds(primary);
jsTestLog("Waiting for PRIMARY(" + primary.host + ") to step down & become SECONDARY.");
replTest.waitForState(primary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [primary]);
//
// Disable failpoints and stop replica set

View File

@ -22,7 +22,7 @@ jsTestLog("Trying to step down primary.");
assert.commandWorked(primary.adminCommand({replSetStepDown: 60, secondaryCatchUpPeriodSecs: 60}));
jsTestLog("Waiting for PRIMARY(" + primary.host + ") to step down & become SECONDARY.");
replTest.waitForState(primary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [primary]);
// Wait until the config has propagated to the secondary and the primary has learned of it, so that
// the config replication check is satisfied.

View File

@ -25,7 +25,7 @@ assert.eq(primary, rst.nodes[0]);
jsTestLog("Adding node 2");
const newNode = rst.add({});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
rst.awaitReplication();
rst.awaitSecondaryNodes();

View File

@ -20,7 +20,7 @@ jsTestLog("Adding node 1");
const newNode = rst.add({});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [newNode]);
rst.awaitReplication();
rst.awaitSecondaryNodes();

View File

@ -54,7 +54,7 @@ assert.commandWorked(bucketsColl.insert(bucket));
const secondary = replTest.add();
replTest.reInitiate();
replTest.waitForState(secondary, ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [secondary]);
replTest.awaitReplication();
const primaryColl = primary.getDB(db.getName())[bucketsColl.getName()];

View File

@ -153,6 +153,6 @@ assert.soonNoExcept(() => !tooStale(replTest.nodes[2]), "Waiting for Node 2 to e
assert.soon(() => myState(replTest.nodes[2]) === ReplSetTest.State.SECONDARY,
"Waiting for Node 2 to transition to SECONDARY");
// This waits for the state as indicated by the primary node.
replTest.waitForState(replTest.nodes[2], ReplSetTest.State.SECONDARY);
replTest.awaitSecondaryNodes(null, [replTest.nodes[2]]);
replTest.stopSet();

View File

@ -47,7 +47,7 @@ function runStepDown() {
assert.commandWorked(primaryAdmin.runCommand({"replSetStepDown": 30 * 60, "force": true}));
// Wait until the primary transitioned to SECONDARY state.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [primary]);
jsTestLog("Validating data.");
assert.docEq([{_id: 'readOp'}], primaryColl.find().toArray());

View File

@ -55,7 +55,7 @@ jsTest.log("Step up Node B in term 2. Commit a new write.");
// Ensure Node B is caught up, so that it can become primary.
rst.awaitReplication(undefined, undefined, [nodeB]);
assert.commandWorked(nodeB.adminCommand({replSetStepUp: 1}));
rst.waitForState(nodeA, ReplSetTest.State.SECONDARY);
rst.awaitSecondaryNodes(null, [nodeA]);
assert.eq(nodeB, rst.getPrimary());
assert.commandWorked(
nodeB.getDB(dbName)[collName].insert({_id: "term 2"}, {writeConcern: {w: "majority"}}));

Some files were not shown because too many files have changed in this diff Show More