diff options
author | Kaitlin Mahar <kaitlin.mahar@mongodb.com> | 2023-05-01 16:51:24 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-01 18:49:21 +0000 |
commit | 30d3ac6fac2b5e5f82520ba3ea68f1bc04d19b70 (patch) | |
tree | fca283fc2120e059a64b85d70ad938d6a3b68fb4 /jstests/replsets | |
parent | 2ef56b7743d1d5e090b639f680c45f90d3bbcab4 (diff) | |
download | mongo-30d3ac6fac2b5e5f82520ba3ea68f1bc04d19b70.tar.gz |
SERVER-76695 initial_sync_nodes_maintain_and_gossip_commit_point.js should wait longer for initial sync node to advance commit point
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/initial_sync_nodes_maintain_and_gossip_commit_point.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/jstests/replsets/initial_sync_nodes_maintain_and_gossip_commit_point.js b/jstests/replsets/initial_sync_nodes_maintain_and_gossip_commit_point.js index 9b79b672611..c5f485d5f5f 100644 --- a/jstests/replsets/initial_sync_nodes_maintain_and_gossip_commit_point.js +++ b/jstests/replsets/initial_sync_nodes_maintain_and_gossip_commit_point.js @@ -118,15 +118,21 @@ assert.eq(1, rs.compareOpTimes(thirdCommitPointSecondary, secondCommitPointSecon hangBeforeCompletingOplogFetching.off(); hangBeforeFinish.wait(); -// Verify that the initial sync node receives the commit point from the primary via oplog fetching. +// Verify that the initial sync node receives the commit point from the primary, either via oplog +// fetching or by a heartbeat. This will usually happen via oplog fetching but in some cases it is +// possible that the OplogFetcher shuts down before this ever happens. See SERVER-76695 for details. // We only assert that it is greater than or equal to the second commit point because it is possible // for the commit point to not yet be advanced by the primary when we fetch the oplog entry. -const commitPointInitialSyncNode = getLastCommittedOpTime(initialSyncNode); -assert.gte( - rs.compareOpTimes(commitPointInitialSyncNode, secondCommitPointPrimary), - 0, - `commit point on initial sync node should be at least as up-to-date as the second commit point: ${ - tojson(commitPointInitialSyncNode)}`); +assert.soon(() => { + const commitPointInitialSyncNode = getLastCommittedOpTime(initialSyncNode); + // compareOpTimes will throw an error if given an invalid opTime, and if the + // node has not yet advanced its opTime it will still have the default one, + // which is invalid. + if (!globalThis.rs.isValidOpTime(commitPointInitialSyncNode)) { + return false; + } + return rs.compareOpTimes(commitPointInitialSyncNode, secondCommitPointPrimary) >= 0; +}, `commit point on initial sync node should be at least as up-to-date as the second commit point`); // Verify that the non-voting secondary has received the updated commit point via heartbeats from // the initial sync node. |