MongoDB syncingTo change

mongodb

I have a 3 members replica set version 2.6.1 with following configuration

                    "_id" : 0,
                    "host" : "10.125.16.22:30000",
                    "priority" : 2

                    "_id" : 1,
                    "host" : "10.125.16.22:40000"

                    "_id" : 2,
                    "host" : "10.125.16.22:60000",
                    "priority" : 0,
                    "slaveDelay" : 3600,
                    "hidden" : true

And i want id:2 to sync from id:1.

I execute

db.adminCommand( { replSetSyncFrom: "10.125.16.22:40000" } ) 

and got

"syncFromRequested" : "10.125.16.22:40000",
"prevSyncTarget" : "10.125.16.22:30000",
"ok" : 1

But on rs.status the sync is still syncingTo : "10.125.16.22:30000"

I found on documentation:

Changed in version 2.4: The sync target falls more than 30 seconds
behind another member of the replica set; the mongod will revert to
the default sync target.

Is this what happened in my case? if yes is there any workaround?

Best Answer

There isn't enough information here to know if the "sync target falling more than 30s behind" was the case, but it seems likely if you are pushing through a lot of activity with all of your replica set nodes on the same machine.

There should be some log entries confirming the change; if you're still on 2.6 you should be able to grep for:

 changing sync target because current sync target's most recent OpTime is

One thing to note is that rs.syncFrom() is a temporary change. By default the sync targets are automatically chosen by MongoDB, and will be reset if you restart instances or lose connectivity.

There's a helpful open source tool called Edda which you can use to process MongoDB log files and visualise changes in replica set history. NOTE: The github repository has changed since that blog post was published; the current repo is 10gen-labs/edda.