`rs.printSecondaryReplicationInfo()` is a mongosh helper for checking how far secondary replica-set members lag behind the primary. The equivalent `db.printSecondaryReplicationInfo()` output identifies each member, when it last synchronized, and its replication lag. section 9.1.3 section 21.2.3
Listing 9.6 Output of the db.printSecondaryReplicationInfo() command
db.printSecondaryReplicationInfo()
source: ac-5dhjxpf-shard-00-00.fpomkke.mongodb.net:27017
{
syncedTo: 'Wed Mar 27 2024 18:21:52 GMT+0000
➥(Coordinated Universal Time)',
replLag: '0 secs (0 hrs) behind the primary '
}
---
source: ac-5dhjxpf-shard-00-01.fpomkke.mongodb.net:27017
{
syncedTo: 'Wed Mar 27 2024 18:21:53 GMT+0000
➥(Coordinated Universal Time)',
replLag: '10 secs (0 hrs) behind the primary '
}
The sample `db.printSecondaryReplicationInfo()` output shows one member at 0 seconds of lag and another 10 seconds behind the primary. Compare each member’s `replLag` when checking whether secondaries are keeping up. section 9.1.3
Lag matters when an application reads from secondaries: a lagging member may serve outdated data. The helper prints human-readable output rather than JSON; use `rs.status()` instead for automated scripts. Check oplog capacity separately when investigating whether a secondary can catch up after a pause. section 9.1.3 section 21.2.3
