[SERVER-2481] SlaveOK queries shouldn't go to slaves in RECOVERING state Created: 04/Feb/11  Updated: 12/Jul/16  Resolved: 16/Jun/11

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 1.8.3, 1.9.1

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Greg Studer
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by auto [ 11/Jul/11 ]

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: backport of fix for SERVER-2481
Branch: v1.8
https://github.com/mongodb/mongo/commit/3337ab497cd55e25fbdbe732e6c40c724add857d

Comment by auto [ 16/Jun/11 ]

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: better logic for no-result in rs for parallel ops SERVER-2481
Branch: master
https://github.com/mongodb/mongo/commit/884e100ec01d21f493c327a72b92a5b1a5dfb440

Comment by auto [ 16/Jun/11 ]

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: tests for parallel cursor and failover SERVER-2481
Branch: master
https://github.com/mongodb/mongo/commit/3316127d58babf98830a8f59fbb16c222df88107

Comment by auto [ 16/Jun/11 ]

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: parallel cursor recover gracefully from replica set and other errors SERVER-2481
Branch: master
https://github.com/mongodb/mongo/commit/4d8ee4cc7c4d32ace1b1cab403dd429d9467a677

Comment by Greg Studer [ 06/Jun/11 ]

New parallel cursor has this behavior as well.

Comment by Greg Studer [ 01/Jun/11 ]

Wrong ticket for commit, but this addresses the problem (had two jira cases open)

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: check for not master or secondary error on slave queries, re-route SERVER-2481
Branch: master
https://github.com/mongodb/mongo/commit/b2236461fa760ee455108fbf14ccf3099ff75187

Comment by Y. Wayne Huang [ 23/May/11 ]

any updates on this? it makes slaveOk unusable.

Generated at Thu Feb 08 03:00:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.