The MongoDB replica health check reports an idle replica as 15 seconds behind on its first check #432

Closed
opened 2026-11-13 16:42:34 -05:00 by claude · 0 comments
Owner

What happened

MongoDbReplicaHealthTests.Monitor_OnAnIdleReplicaSet_KeepsTheReplicaEligible failed once on the Linux runner, in the Test .NET job of the develop push run 1611 (the merge of #429, a change to workflows and documents only):

Check 1 found the idle replica not eligible: The replica is 15 s behind, more than the limit of 5 s.
   at ...MongoDbReplicaHealthTests.Monitor_OnAnIdleReplicaSet_KeepsTheReplicaEligible() in MongoDbReplicaHealthTests.cs:line 63

The next develop run (the merge of #428, which contains the same code) was green.

Why this may be more than a slow runner

The test waits 15 seconds with no writes and then starts the monitor. The very first check reported the replica exactly that long behind. That is the mistake #61 was about: on an idle replica set an old optime is not lag. So the first check after an idle period can still read an old secondary optime against a fresh primary optime (for example right after the primary's periodic no-op write, before the secondary has reported it), and one such reading makes the replica ineligible.

Wanted

  • Find out from the monitor's code how lag is computed on the first check and whether the primary's no-op write can produce this reading on an idle set. Reproduce it if possible (the test repeated a bounded number of times, or a test that forces the order of the two optime reads).
  • If the product can report false lag: fix the measurement (for example compare against the secondary's last applied time relative to the primary's last write as the server reports both in one reply, or require a second reading before a replica loses eligibility; choose from what MongoDB's documentation says about the fields used) and add a test that fails without the fix.
  • If it is only the test's timing on a loaded runner: make the test robust without weakening what it guards, and say why the product is not affected.
  • Operator view: a replica wrongly marked ineligible sends reads to the primary until the next check, so this is a performance blip, not a correctness problem; confirm that reading by the code.

Related: #61 (the same measurement), #352 and #386 (other MongoDB replica test problems).

**What happened** `MongoDbReplicaHealthTests.Monitor_OnAnIdleReplicaSet_KeepsTheReplicaEligible` failed once on the Linux runner, in the Test .NET job of the `develop` push run 1611 (the merge of #429, a change to workflows and documents only): ``` Check 1 found the idle replica not eligible: The replica is 15 s behind, more than the limit of 5 s. at ...MongoDbReplicaHealthTests.Monitor_OnAnIdleReplicaSet_KeepsTheReplicaEligible() in MongoDbReplicaHealthTests.cs:line 63 ``` The next `develop` run (the merge of #428, which contains the same code) was green. **Why this may be more than a slow runner** The test waits 15 seconds with no writes and then starts the monitor. The very first check reported the replica exactly that long behind. That is the mistake #61 was about: on an idle replica set an old optime is not lag. So the first check after an idle period can still read an old secondary optime against a fresh primary optime (for example right after the primary's periodic no-op write, before the secondary has reported it), and one such reading makes the replica ineligible. **Wanted** - Find out from the monitor's code how lag is computed on the first check and whether the primary's no-op write can produce this reading on an idle set. Reproduce it if possible (the test repeated a bounded number of times, or a test that forces the order of the two optime reads). - If the product can report false lag: fix the measurement (for example compare against the secondary's last applied time relative to the primary's last write as the server reports both in one reply, or require a second reading before a replica loses eligibility; choose from what MongoDB's documentation says about the fields used) and add a test that fails without the fix. - If it is only the test's timing on a loaded runner: make the test robust without weakening what it guards, and say why the product is not affected. - Operator view: a replica wrongly marked ineligible sends reads to the primary until the next check, so this is a performance blip, not a correctness problem; confirm that reading by the code. Related: #61 (the same measurement), #352 and #386 (other MongoDB replica test problems).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil#432
No description provided.