MongoCursorException Error

111 views
Skip to first unread message

Rajkishore Singh

unread,
Mar 1, 2012, 8:05:27 AM3/1/12
to mongodb-user
Hi all,

I am getting some error at random time....

Error:

URL /root/recoly/crons/send_mailer.php 1 Uncaught exception
'MongoCursorException' with message 'setShardVersion failed host:
x.x.x.x:10011 { oldVersion: Timestamp 0|0, ns: "recommendly.pages",
version: Timestamp 3000|0, globalVersion: Timestamp 2000|0, errmsg:
"client version differs from config's for collection
'recommendly.pages'", ok: 0.0 }' in /root/recoly/crons/send_mailer.php:
21 Stack trace: #0 /root/recoly/crons/send_mailer.php(21): MongoCursor-
>rewind() #1 {main} thrown in /root/recoly/crons/send_mailer.php:21



we are using Sharded Mongo with 3 replicaset, 3 config server & 5-10
mongos(we are runing one mongos on each machine from where we are
accessing mongo). so, currently we have 8 mongos on 8 different
machine.

as per given in the error msg that we get error at line no 21,

Here some partial code of that file

Line No: 17 $pages = $pages_model->find(array('status' => 4,
'is_active' => 1, 'mail_time' => array('$gte'=> $min, '$lt'=> $max),
'subscribed' => 1));
LNo: 18 //$pages = $pages_model->find(array('status' => 4, 'id' =>
'249343554283')); // for testing
LNo: 19 $pages_count = $pages->count();
LNo: 20 if($pages_count > 0) {
LNo: 21 foreach ($pages as $page) {
LNo: 22 var_dump($page);
LNo: 23 $stats = Load::Library('mailerStats', array('page_id'
=> $page['id'], 'user_id' => $page['user_id']));
LNo: 24 $stats->dataExists($page);
LNo: 25 $stats->sendEmail($page);
LNo: 26 }
LNo: 27 }


Shard key of the collection which is pointed by $pages_model is "id".

can any body tell me, what could be the reason for the above error
msg...

as we can see in line no 17, I am not using shard_key in find
query....so, will this is reason for this error. but some times we get
error some time not.

generally we get 2-3 times in 24 hrs...

please reply...

Thanks

Raj

Raxit Sheth

unread,
Mar 1, 2012, 8:34:28 AM3/1/12
to mongod...@googlegroups.com
Which version ? Can you try on latest ?

PS : not clear about your arch, just checked few history mail and
there were some bug.

Raxit

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>

Kristina Chodorow

unread,
Mar 1, 2012, 11:01:55 AM3/1/12
to mongod...@googlegroups.com
StaleConfigException means that the mongos you're querying has an old version of the sharding config because some of it moved to another shard and it hasn't updated its config yet.  Generally you can just catch this exception, retry the query, and it'll work.

Rajkishore Singh

unread,
Mar 1, 2012, 11:57:32 PM3/1/12
to mongodb-user
MongoDB version 2.0.2

Rajkishore Singh

unread,
Mar 2, 2012, 12:01:29 AM3/2/12
to mongodb-user
ok, thanks...
I had same idea... but I think it should be handle by mongo?
is there any other way to handle this issue at mongo side?

Kristina Chodorow

unread,
Mar 5, 2012, 4:33:39 PM3/5/12
to mongod...@googlegroups.com
Mongos should handle most of these, but sometimes it cannot and it'll slip through to the client (e.g., suppose it cannot reach the config servers so it cannot update its config... what should it return to the client?).  So you'll have to handle it in your application.

Rajkishore Singh

unread,
Mar 6, 2012, 1:50:01 AM3/6/12
to mongodb-user
ok fine,
can we force mongos to update new config?
I mean to say, is there any command to check & compare config version
at mongos side and force mongos to update latest config date?

Kristina Chodorow

unread,
Mar 6, 2012, 11:03:18 AM3/6/12
to mongod...@googlegroups.com
No, it can't always update the config, that's why your application has to handle it.
Reply all
Reply to author
Forward
0 new messages