The MongoDB replica health check measures lag correctly on an idle replica set #313
No reviewers
Labels
No labels
agent
api-regen
agent
architect
agent
coder
agent
console-coder
agent
docs-writer
agent
mechanic
agent
protocol-coder
agent
storage-coder
area/api
area/ci
area/console
area/dhcp
area/dns
area/docs
area/packaging
area/process
area/storage
area/windows
kind
bug
kind
chore
kind
docs
kind
epic
kind
feature
kind
performance
kind
security
kind
test
priority
high
priority
low
priority
medium
resolution
duplicate
resolution
not-a-bug
resolution
wontfix
status
blocked
status
in-progress
status
needs-decision
status
needs-design
status
ready
theme
ad-samba-dns
theme
alternatives-benchmark
theme
console-toolchain
theme
later
theme
parity-devices
theme
parity-query
theme
post-release-fixes
theme
tracker-setup
theme
valkey
theme
windows-installer
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lantea-one/ninlil!313
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/61-mongo-idle-replica-lag"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The MongoDB replica health check no longer refuses a healthy secondary of an idle replica set, and never reports a lagging secondary below its lag.
Measured on the pinned
mongo:8image: an idle set writes a no-op about every 20 s; a secondary'slastAppliedWallTime(ms) matches the primary's at once, while itsoptime/optimeDateinreplSetGetStatustrail by up to one heartbeat (~2 s), which produced a false "17 s behind" (red test on develop:Check 3 found the idle replica not eligible: The replica is 17 s behind, more than the limit of 5 s.).Rule (
MongoReplicaLag, stateless, called byMongoReplicaHealthProbe):lastAppliedWallTimeequals the primary's, however old that operation is.date(the primary's clock) minus the secondary's last applied wall time (optimeDateas fallback). This is an upper bound of how long it may have been missing data, on every check, including the first after a start. The gap between the two members' last operations is not a bound (a write followed by an idle pause leaves a millisecond gap while the secondary misses data), so it is not used.Tests:
MongoDbReplicaHealthTests.Monitor_OnAnIdleReplicaSet_KeepsTheReplicaEligible(Docker; 15 s idle then 30 s of checks; red on develop); the paused-replication test still falls back to the primary;MongoReplicaLagTests(9 unit tests on crafted status documents, including a secondary far behind at its first check and a missed write before an idle pause).MongoDbReplicaRoutingTests10/10 runs on the first version and 3/3 after the final rule change; Integration Mongo filter, Data.Tests 133 pass; build 0 warnings; csharpier clean. README read-replica bullet updated.Closes #61
🤖 Generated with Claude Code
https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK