Docs Menu
Docs Home
/
MongoDB Manual
/ / /

db.printSecondaryReplicationInfo()

On this page

  • Definition
  • Output
db.printSecondaryReplicationInfo()

Prints a formatted report of the replica set status from the perspective of the secondary member of the set. The output is identical to the rs.printSecondaryReplicationInfo() method.

Example db.printSecondaryReplicationInfo() output when run on a replica set with two secondary members:

source: m1.example.net:27002
syncedTo: Mon Mar 01 2021 16:30:50 GMT-0800 (PST)
0 secs (0 hrs) behind the primary
source: m2.example.net:27003
syncedTo: Mon Mar 01 2021 16:30:50 GMT-0800 (PST)
0 secs (0 hrs) behind the primary

Note

The db.printSecondaryReplicationInfo() method run in mongosh does not return JSON. Use db.printSecondaryReplicationInfo() for manual inspection, and rs.status() in scripts.

A delayed member may show as 0 seconds behind the primary when the inactivity period on the primary is greater than the members[n].secondaryDelaySecs value.

A member may show a negative time value behind the primary when db.printSecondaryReplicationInfo() is run. This is expected if db.printSecondaryReplicationInfo() is run after a secondary replicates a write that follows a period of inactivity, but before the secondary receives a heartbeat from the primary with the latest optime.

Note

The lag reported by secondaries may not be representative of cluster health. Negative values do not indicate that the secondary is ahead of the primary.

To obtain the most current status for your replica set, run db.printSecondaryReplicationInfo() on the primary.

Back

db.printReplicationInfo()

On this page