mongodb游标ID无效错误 [英] mongodb cursor id not valid error

查看:109
本文介绍了mongodb游标ID无效错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遍历此循环:

I am trying to iterate through this loop:

for doc in coll.find()

我在第100,000个以上的记录中收到以下错误.

I get the following error at the 100,000th plus record.

File "build\bdist.win32\egg\pymongo\cursor.py", line 703, in next
File "build\bdist.win32\egg\pymongo\cursor.py", line 679, in _refresh
File "build\bdist.win32\egg\pymongo\cursor.py", line 628, in __send_message
File "build\bdist.win32\egg\pymongo\helpers.py", line 95, in _unpack_response
pymongo.errors.OperationFailure: cursor id '1236484850793' not valid at server

此错误是什么意思?

推荐答案

也许您的光标在服务器上超时了.要查看这是否是问题,请尝试将timeout = False设置为:

Maybe your cursor timed out on the server. To see if this is the problem, try to set timeout=False`:

for doc in coll.find(timeout=False)

请参见 http://api .mongodb.org/python/1.6/api/pymongo/collection.html#pymongo.collection.Collection.find

如果是超时问题,一种可能的解决方案是设置batch_size(其他答案).

If it was a timeout problem one possible solution is to set the batch_size (s. other answers).

这篇关于mongodb游标ID无效错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆