MongoDB – Re-evaluating Sync Source Log Entries When chainingAllowed is False

mongodbmongodb-3.2nosql

We have recently upgraded our 3 member replica set from 3.0 to 3.2.9. Since the upgrade, we are seeing log entries like below periodically on one of the secondaries.
As per the rs.conf() output below, we having chainingAllowed = false and all secondaries are syncing from the primary so I would not expect to see these log entries.

Primary – mongodb01
Secondaries – mongodb02 & mongodb03

The log entries seem to show that the secondary mongodb02 is syncing from the other secondary mongodb03. So is the chainingAllowed setting being observed? Does anyone know why we are seeing these messages?

Thanks.

Log Entries

2016-09-06T08:51:12.029+0100 I REPL     [ReplicationExecutor] re-evaluating sync source because our current sync source's most recent OpTime is (term: -1, timestamp: Sep  6 08:50:35:1) which is more than 30s behind member mongodb03:27017 whose most recent OpTime is (term: -1, timestamp: Sep  6 08:51:11:1)
2016-09-06T08:51:12.029+0100 I REPL     [ReplicationExecutor] syncing from primary: mongodb01:27017
2016-09-06T08:51:12.034+0100 I REPL     [ReplicationExecutor] re-evaluating sync source because our current sync source's most recent OpTime is (term: -1, timestamp: Sep  6 08:50:35:1) which is more than 30s behind member mongodb03:27017 whose most recent OpTime is (term: -1, timestamp: Sep  6 08:51:11:1)
2016-09-06T08:51:12.034+0100 I REPL     [ReplicationExecutor] syncing from primary: mongodb01:27017
2016-09-06T08:51:12.041+0100 I REPL     [ReplicationExecutor] re-evaluating sync source because our current sync source's most recent OpTime is (term: -1, timestamp: Sep  6 08:50:35:1) which is more than 30s behind member mongodb03:27017 whose most recent OpTime is (term: -1, timestamp: Sep  6 08:51:11:1)
2016-09-06T08:51:12.042+0100 I REPL     [ReplicationExecutor] syncing from primary: mongodb01:27017
2016-09-06T08:51:12.049+0100 I REPL     [ReplicationExecutor] re-evaluating sync source because our current sync source's most recent OpTime is (term: -1, timestamp: Sep  6 08:50:35:1) which is more than 30s behind member mongodb03:27017 whose most recent OpTime is (term: -1, timestamp: Sep  6 08:51:11:1)
2016-09-06T08:51:12.049+0100 I REPL     [ReplicationExecutor] syncing from primary: mongodb01:27017

rs.conf()

mongodbrepl:SECONDARY> rs.conf()
{
        "_id" : "mongodbrepl",
        "version" : 32,
        "members" : [
                {
                        "_id" : 2,
                        "host" : "mongodb03:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                },
                {
                        "_id" : 1,
                        "host" : "mongodb02:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 0,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                },
                {
                        "_id" : 0,
                        "host" : "mongodb01:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "settings" : {
                "chainingAllowed" : false,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                }
        }
}

rs.status()

mongodbrepl:SECONDARY> rs.status()
{
        "set" : "mongodbrepl",
        "date" : ISODate("2016-09-06T08:24:13.763Z"),
        "myState" : 2,
        "term" : NumberLong(-1),
        "syncingTo" : "mongodb01:27017",
        "heartbeatIntervalMillis" : NumberLong(2000),
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongodb01:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 412082,
                        "optime" : Timestamp(1473150251, 1),
                        "optimeDate" : ISODate("2016-09-06T08:24:11Z"),
                        "lastHeartbeat" : ISODate("2016-09-06T08:24:13.461Z"),
                        "lastHeartbeatRecv" : ISODate("2016-09-06T08:24:13.462Z"),
                        "pingMs" : NumberLong(0),
                        "electionTime" : Timestamp(1472738228, 1),
                        "electionDate" : ISODate("2016-09-01T13:57:08Z"),
                        "configVersion" : 32
                },
                {
                        "_id" : 1,
                        "name" : "mongodb02:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 412280,
                        "optime" : Timestamp(1473150251, 1),
                        "optimeDate" : ISODate("2016-09-06T08:24:11Z"),
                        "syncingTo" : "mongodb01:27017",
                        "configVersion" : 32,
                        "self" : true
                },
                {
                        "_id" : 2,
                        "name" : "mongodb03:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 412273,
                        "optime" : Timestamp(1473150251, 1),
                        "optimeDate" : ISODate("2016-09-06T08:24:11Z"),
                        "lastHeartbeat" : ISODate("2016-09-06T08:24:12.395Z"),
                        "lastHeartbeatRecv" : ISODate("2016-09-06T08:24:13.757Z"),
                        "pingMs" : NumberLong(0),
                        "syncingTo" : "mongodb01:27017",
                        "configVersion" : 32
                }
        ],
        "ok" : 1
}

Best Answer

It's hard to say without seeing all the logs, but I suspect you are seeing changes to your primary. The primary is listed in the log messages as primary: mongodb01 and it is (at the time syncing from mongodb03). It's the kind of thing I would expect to see if you were stepping down the primary (mongodb03), then locking it (or similar) that causes it to fall behind and mongodb02 notices and switches to the new primary (mongodb01).

Your status indicates that mongodb03 is once again the primary when you ran it, but the logs clearly show that mongodb01 has been the primary in the past.

Related Question