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

SlaveOK queries shouldn't go to slaves in RECOVERING state

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8.3, 1.9.1
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • ALL

      mongo shell connected to mongos with single replica set shard

      > db.foo.find().itcount()
      1000
      > db.getMongo().setSlaveOk()
      > db.foo.find().itcount()
      Fri Feb 4 16:21:22 uncaught exception: error:

      { "$err" : "not master or secondary, can't read", "code" : 13436 }

      > db.getMongo().slaveOk = false
      false
      > db.foo.find().itcount()
      1000

      connecting directly to replSet:

      rs.status()
      {
      "set" : "slave_ok_no_master",
      "date" : ISODate("2011-02-04T21:21:07Z"),
      "myState" : 1,
      "members" : [
      {
      "_id" : 0,
      "name" : "redbeard:31000",
      "health" : 1,
      "state" : 1,
      "stateStr" : "PRIMARY",
      "optime" :

      { "t" : 1296854198000, "i" : 302 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:38Z"),
      "self" : true
      },
      {
      "_id" : 1,
      "name" : "redbeard:31001",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 372,
      "optime" :

      { "t" : 1296854197000, "i" : 176 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:37Z"),
      "lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
      "errmsg" : "error RS102 too stale to catch up"
      },
      {
      "_id" : 2,
      "name" : "redbeard:31002",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 372,
      "optime" :

      { "t" : 1296854197000, "i" : 2 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:37Z"),
      "lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
      "errmsg" : "error RS102 too stale to catch up"
      },
      {
      "_id" : 3,
      "name" : "redbeard:31003",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 382,
      "optime" :

      { "t" : 1296854197000, "i" : 54 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:37Z"),
      "lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
      "errmsg" : "error RS102 too stale to catch up"
      },
      {
      "_id" : 4,
      "name" : "redbeard:31004",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 372,
      "optime" :

      { "t" : 1296854197000, "i" : 202 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:37Z"),
      "lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
      "errmsg" : "error RS102 too stale to catch up"
      },
      {
      "_id" : 5,
      "name" : "redbeard:31005",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 372,
      "optime" :

      { "t" : 1296854197000, "i" : 51 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:37Z"),
      "lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
      "errmsg" : "error RS102 too stale to catch up"
      },
      {
      "_id" : 6,
      "name" : "redbeard:31006",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 382,
      "optime" :

      { "t" : 1296854197000, "i" : 10 }

      ,
      "optimeDate" : ISODate("2011-02-04T21:16:37Z"),
      "lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
      "errmsg" : "error RS102 too stale to catch up"
      }
      ],
      "ok" : 1
      }
      > db.setSlaveOk()
      > db.foo.find().itcount()
      1000

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: