Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6475

replSetSyncFrom can break replication

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 2.1.2
    • Component/s: Replication
    • ALL

      It is possible to configure two secondaries to sync from each other, breaking replication for both:

      MongoDB shell version: 2.1.3-pre-
      connecting to: 127.0.0.1:27018/test
      foo:SECONDARY> rs.syncFrom('behackett-dt:27019')
      {
      	"syncFromRequested" : "behackett-dt:27019",
      	"prevSyncTarget" : "behackett-dt:27017",
      	"ok" : 1
      }
      foo:SECONDARY> rs.status()
      {
      	"set" : "foo",
      	"date" : ISODate("2012-07-17T00:23:47Z"),
      	"myState" : 2,
      	"syncingTo" : "behackett-dt:27019",
      	"members" : [
      		{
      			"_id" : 0,
      			"name" : "behackett-dt:27017",
      			"health" : 1,
      			"state" : 1,
      			"stateStr" : "PRIMARY",
      			"uptime" : 131,
      			"optime" : Timestamp(1342483505000, 1),
      			"optimeDate" : ISODate("2012-07-17T00:05:05Z"),
      			"lastHeartbeat" : ISODate("2012-07-17T00:23:46Z"),
      			"pingMs" : 0
      		},
      		{
      			"_id" : 1,
      			"name" : "behackett-dt:27018",
      			"health" : 1,
      			"state" : 2,
      			"stateStr" : "SECONDARY",
      			"uptime" : 131,
      			"optime" : Timestamp(1342483505000, 1),
      			"optimeDate" : ISODate("2012-07-17T00:05:05Z"),
      			"errmsg" : "syncing to: behackett-dt:27019 by request",
      			"self" : true
      		},
      		{
      			"_id" : 2,
      			"name" : "behackett-dt:27019",
      			"health" : 1,
      			"state" : 2,
      			"stateStr" : "SECONDARY",
      			"uptime" : 131,
      			"optime" : Timestamp(1342483505000, 1),
      			"optimeDate" : ISODate("2012-07-17T00:05:05Z"),
      			"lastHeartbeat" : ISODate("2012-07-17T00:23:46Z"),
      			"pingMs" : 0,
      			"errmsg" : "syncing to: behackett-dt:27018 by request"
      		},
      		{
      			"_id" : 3,
      			"name" : "behackett-dt:27020",
      			"health" : 1,
      			"state" : 7,
      			"stateStr" : "ARBITER",
      			"uptime" : 129,
      			"lastHeartbeat" : ISODate("2012-07-17T00:23:46Z"),
      			"pingMs" : 0
      		}
      	],
      	"ok" : 1
      }
      

      Subsequent write operations are not replicated to either:

      foo:SECONDARY> rs.status()
      {
      	"set" : "foo",
      	"date" : ISODate("2012-07-17T00:26:06Z"),
      	"myState" : 2,
      	"syncingTo" : "behackett-dt:27019",
      	"members" : [
      		{
      			"_id" : 0,
      			"name" : "behackett-dt:27017",
      			"health" : 1,
      			"state" : 1,
      			"stateStr" : "PRIMARY",
      			"uptime" : 270,
      			"optime" : Timestamp(1342484759000, 2),
      			"optimeDate" : ISODate("2012-07-17T00:25:59Z"),
      			"lastHeartbeat" : ISODate("2012-07-17T00:26:04Z"),
      			"pingMs" : 0
      		},
      		{
      			"_id" : 1,
      			"name" : "behackett-dt:27018",
      			"health" : 1,
      			"state" : 2,
      			"stateStr" : "SECONDARY",
      			"uptime" : 270,
      			"optime" : Timestamp(1342483505000, 1),
      			"optimeDate" : ISODate("2012-07-17T00:05:05Z"),
      			"self" : true
      		},
      		{
      			"_id" : 2,
      			"name" : "behackett-dt:27019",
      			"health" : 1,
      			"state" : 2,
      			"stateStr" : "SECONDARY",
      			"uptime" : 270,
      			"optime" : Timestamp(1342483505000, 1),
      			"optimeDate" : ISODate("2012-07-17T00:05:05Z"),
      			"lastHeartbeat" : ISODate("2012-07-17T00:26:04Z"),
      			"pingMs" : 0
      		},
      		{
      			"_id" : 3,
      			"name" : "behackett-dt:27020",
      			"health" : 1,
      			"state" : 7,
      			"stateStr" : "ARBITER",
      			"uptime" : 268,
      			"lastHeartbeat" : ISODate("2012-07-17T00:26:04Z"),
      			"pingMs" : 0
      		}
      	],
      	"ok" : 1
      }
      foo:SECONDARY> db.printSlaveReplicationInfo()
      source:   behackett-dt:27018
      	 syncedTo: Mon Jul 16 2012 17:05:05 GMT-0700 (PDT)
      		 = 1505 secs ago (0.42hrs)
      source:   behackett-dt:27019
      	 syncedTo: Mon Jul 16 2012 17:05:05 GMT-0700 (PDT)
      		 = 1505 secs ago (0.42hrs)
      source:   behackett-dt:27020
      	 no replication info, yet.  State: ARBITER
      

      Secondaries should check that the requested source isn't already syncing from themselves.

            Assignee:
            Unassigned Unassigned
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: