Replication Info Results Always Chaging

Hello,

I got the following log output below. Why is the delay always changing from 0 to 3,5,7 seconds then back to 0? Is this normal? There are no queries performed to the mongodb database during the checking of the replication info.

myshard01:PRIMARY> db.printSlaveReplicationInfo()
source: node01:27018
        syncedTo: Fri Aug 28 2020 07:27:18 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
source: node03:27018
        syncedTo: Fri Aug 28 2020 07:27:18 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
myshard01:PRIMARY>
myshard01:PRIMARY> db.printSlaveReplicationInfo()
source: node01:27018
        syncedTo: Fri Aug 28 2020 07:27:18 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
source: node03:27018
        syncedTo: Fri Aug 28 2020 07:27:18 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
myshard01:PRIMARY>
myshard01:PRIMARY> db.printSlaveReplicationInfo()
source: node01:27018
        syncedTo: Fri Aug 28 2020 07:27:18 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
source: node03:27018
        syncedTo: Fri Aug 28 2020 07:27:18 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
myshard01:PRIMARY>

I’m sorry, logs were trimmed. Basically, I want to understand the following:

  1. First-Third execution of db.printSlaveReplicationInfo() results to “0 secs (0 hrs) behind the primary”
  2. Fourth execution of db.printSlaveReplicationInfo() results to “4 secs (0 hrs) behind the primary”
  3. Fifth and Sixth execution of db.printSlaveReplicationInfo() results to “2 secs (0 hrs) behind the primary”
  4. Seventh-Tenth execution of db.printSlaveReplicationInfo() results to “0 secs (0 hrs) behind the primary”

Why is the lag always changing even if there are no changes or queries executed?

Even if there is no actual data changes in your user collections, the oplog keeps moving ahead and there is also communication between internal components of MongoDB replica set members. For example, “HeartBeat” exchange is one of the most important mechanism for replica set members to know the status of each other in a replica set.

1 Like

Thank you very much for your response, Zhen.