[SERVER-2482] SlaveOK queries and getMores need to go to same member Created: 04/Feb/11  Updated: 12/Jul/16  Resolved: 05/Feb/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 1.7.6

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

> var rt = new ReplSetTest(

{nodes:7, name:'slave_ok_no_master'}

);
> rt.startSet(

{oplogSize:200}

)
> rt.initiate()

Start up a mongos with rt.getURL() as a shard() and connect

> s='x'
x
> while (s.length < 128*1024) s += s; s.length
131072
> for (var i=0; i<1000; i++) db.foo.insert(

{s:s}

)
[takes a little while]
> db.foo.count()
1000
> db.foo.find().itcount()
1000
> db.getMongo().setSlaveOk()
> db.foo.find().itcount()
Fri Feb 4 17:18:30 Error: getMore: cursor didn't exist on server, possible restart or timeout? shell/query.js:104

It looks like the works/doesn't work threshold is 32/33 which is the same threshold where a the results won't fit into a single message:

> db.foo.find().limit(32).itcount()
32
> db.foo.find().limit(33).itcount()
Fri Feb 4 17:28:59 Error: getMore: cursor didn't exist on server, possible restart or timeout? shell/query.js:104
> Object.bsonsize({_id:ObjectId(), s:s})*32
4195264
> Object.bsonsize({_id:ObjectId(), s:s})*33
4326366
> 4*1024*1024
4194304

I added some debugging info into the code and it looks like the getMore is going to the master.



 Comments   
Comment by auto [ 05/Feb/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: fix SlaveOk getMore with replica sets for non sharded collections SERVER-2482
https://github.com/mongodb/mongo/commit/ed2b128e5de0ddd2bf5303fda7980bd1d0b2c683

Comment by auto [ 05/Feb/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: fix SlaveOk getMore with replica sets for sharded collections SERVER-2482
https://github.com/mongodb/mongo/commit/5287de64fbc3bd412c84a23da7280b3c20853f21

Comment by Mathias Stearn [ 04/Feb/11 ]

Because the wire protocol doesn't require GetMore requests to include the query options, I think the only solution will be modifying strategy_stard to store the query options whenever a cursor is created and examine them when doing a get more. Perhaps just need to keep a set of cursors that were sent to a slave.

Note that the C++ driver does send opts in GetMore, but it isn't required, and the python driver (and maybe others) just send zero.

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