Secondary is syncing from another Secondary

I have a 6 node replicaset - 1 Primary, 4 Secondaries and 1 Arbiter.

in rs.status() I can see that the “syncSourceHost” for 3 secondaries is the Primary, while for one secondary the “syncSourceHost” is another secondary.

rs.status()
{
        "set" : "myrs0",
        "date" : ISODate("2022-01-25T08:13:58.958Z"),
        "myState" : 2,
        "term" : NumberLong(1),
        "syncSourceHost" : "1.1.1.150:27002",
        "syncSourceId" : 3,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 4,
        "writeMajorityCount" : 4,
        "votingMembersCount" : 6,
        "writableVotingMembersCount" : 5,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1643098437, 1),
                        "t" : NumberLong(1)
                },
                "lastCommittedWallTime" : ISODate("2022-01-25T08:13:57.590Z"),
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1643098437, 1),
                        "t" : NumberLong(1)
                },
                "appliedOpTime" : {
                        "ts" : Timestamp(1643098437, 1),
                        "t" : NumberLong(1)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1643098437, 1),
                        "t" : NumberLong(1)
                },
                "lastAppliedWallTime" : ISODate("2022-01-25T08:13:57.590Z"),
                "lastDurableWallTime" : ISODate("2022-01-25T08:13:57.590Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1643098407, 1),
        "members" : [
                {
                        "_id" : 0,
                        "name" : "10.103.19.196:27002",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 63492,
                        "optime" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2022-01-25T08:13:57Z"),
                        "optimeDurableDate" : ISODate("2022-01-25T08:13:57Z"),
                        "lastHeartbeat" : ISODate("2022-01-25T08:13:58.863Z"),
                        "lastHeartbeatRecv" : ISODate("2022-01-25T08:13:56.972Z"),
                        "pingMs" : NumberLong(27),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "1.1.1.116:27002",
                        "syncSourceId" : 5,
                        "infoMessage" : "",
                        "configVersion" : 2,
                        "configTerm" : 1
                },
                {
                        "_id" : 1,
                        "name" : "1.1.1.140:27002",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 63492,
                        "optime" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2022-01-25T08:13:57Z"),
                        "optimeDurableDate" : ISODate("2022-01-25T08:13:57Z"),
                        "lastHeartbeat" : ISODate("2022-01-25T08:13:58.729Z"),
                        "lastHeartbeatRecv" : ISODate("2022-01-25T08:13:58.181Z"),
                        "pingMs" : NumberLong(26),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "1.1.1.116:27002",
                        "syncSourceId" : 5,
                        "infoMessage" : "",
                        "configVersion" : 2,
                        "configTerm" : 1
                },
                {
                        "_id" : 3,
                        "name" : "1.1.1.150:27002",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 63492,
                        "optime" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2022-01-25T08:13:57Z"),
                        "optimeDurableDate" : ISODate("2022-01-25T08:13:57Z"),
                        "lastHeartbeat" : ISODate("2022-01-25T08:13:58.609Z"),
                        "lastHeartbeatRecv" : ISODate("2022-01-25T08:13:58.702Z"),
                        "pingMs" : NumberLong(27),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "1.1.1.116:27002",
                        "syncSourceId" : 5,
                        "infoMessage" : "",
                        "configVersion" : 2,
                        "configTerm" : 1
                },
                {
                        "_id" : 4,
                        "name" : "1.1.1.100:27002",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 63515,
                        "optime" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2022-01-25T08:13:57Z"),
                        "syncSourceHost" : "1.1.1.150:27002",
                        "syncSourceId" : 3,
                        "infoMessage" : "",
                        "configVersion" : 2,
                        "configTerm" : 1,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                },
                {
                        "_id" : 5,
                        "name" : "1.1.1.116:27002",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 63492,
                        "optime" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(1643098437, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2022-01-25T08:13:57Z"),
                        "optimeDurableDate" : ISODate("2022-01-25T08:13:57Z"),
                        "lastHeartbeat" : ISODate("2022-01-25T08:13:57.952Z"),
                        "lastHeartbeatRecv" : ISODate("2022-01-25T08:13:57.070Z"),
                        "pingMs" : NumberLong(23),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "electionTime" : Timestamp(1643034954, 1),
                        "electionDate" : ISODate("2022-01-24T14:35:54Z"),
                        "configVersion" : 2,
                        "configTerm" : 1
                },
                {
                        "_id" : 6,
                        "name" : "1.1.1.119:27002",
                        "health" : 1,
                        "state" : 7,
                        "stateStr" : "ARBITER",
                        "uptime" : 63464,
                        "lastHeartbeat" : ISODate("2022-01-25T08:13:58.743Z"),
                        "lastHeartbeatRecv" : ISODate("2022-01-25T08:13:58.291Z"),
                        "pingMs" : NumberLong(26),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "configVersion" : 2,
                        "configTerm" : 1
                }
        ],
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1643098437, 1),
                "signature" : {
                        "hash" : BinData(0,"RXRN39puSbmE4r09/fn0rtj4P+E="),
                        "keyId" : NumberLong("7056781393614864388")
                }
        },
        "operationTime" : Timestamp(1643098437, 1)
}

Why did Mongo choose to sync from another secodnary instead from the Primary?

Thanks,
Tamar

Hi @Tamar_Nirenberg ,
For initialSyncSourceReadPreference set to primaryPreferred (default for voting replica set members), attempt to select the primary as the sync source. If the primary is unavailable or unreachable, perform sync source selection from the remaining replica set members.

Here is the link where you can read more about it:
Replica Set Data Synchronization — MongoDB Manual

Regards

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.