databasemongodbreplicationreplicaset

MongoDB new Replica Set member's syncSourceHost


When i try to add new replicaSet member to my rs, their syncSourceHost's are always different and certainly not PRIMARY node. They all secondaries. Why is that happening? Is there a default setting or we should do like in the document idk if it is possible to add syncSourceHost didnt try it. like:

   _id: <int>,
   host: <string>,        // required
   arbiterOnly: <boolean>,
   buildIndexes: <boolean>,
   hidden: <boolean>,
   priority: <number>,
   tags: <document>,
   secondaryDelaySecs: <int>,
   votes: <number>
}```



Solution

  • From the official mongoDB docs :

    By default secondaries may automatically change their sync targets to secondary members based on changes in the ping time between members and the state of other members’ replication. See Replica Set Data Synchronization and Manage Chained Replication for more information.

    To temporarily override the default sync target selection logic, you may manually configure a secondary member's sync target to temporarily pull oplog entries. The following provide access to this functionality:

    replSetSyncFrom command, or

    rs.syncFrom() helper in mongosh