【问题标题】:Cursor id not valid at server even with no_cursor_timeout=True即使 no_cursor_timeout=True,游标 ID 在服务器上也无效
【发布时间】:2015-06-21 08:05:46
【问题描述】:
Traceback (most recent call last):
  File "from_mongo.py", line 27, in <module>
    for sale in pm.events.find({"type":"sale", "date":{"$gt":now-(_60delta+_2delta)}}, no_cursor_timeout=True, batch_size=100):
  File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 968, in __next__
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 922, in _refresh
self.__id))
  File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 838, in __send_message
codec_options=self.__codec_options)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 110, in _unpack_response
cursor_id)
pymongo.errors.CursorNotFound: cursor id '1025112076089406867' not valid at server

我也尝试过更大或更小的批量大小,根本没有 no_cursor_timeout。我什至设法在一个非常小的集合(200 个带有 id 和标题的文档)上得到这个错误。当数据库没有响应(大量插入)时,似乎会发生这种情况。设置是由 3 个副本集(9 个 mongodb 实例)组成的 3 个分片的集群,mongodb 3.0。

【问题讨论】:

标签: mongodb pymongo


【解决方案1】:

根据您的回溯中的行号,您使用的是上周发布的 PyMongo 3。您是否在分片集群中使用多个 mongos 服务器?如果是这样,该错误可能是 PyMongo 3 中一个严重的新错误的症状:

https://jira.mongodb.org/browse/PYTHON-898

它将在 PyMongo 3.0.1 中修复,我们将在一周内发布。

【讨论】:

  • 你是对的,它实际上是带有多个 mongos+sharding 的 3.0,但在我的开发机器上它是一个不同的版本 (2.8)。
【解决方案2】:

我突然想到我使用的是 pymongo 3.0,它有一个名为 no_cursor_timeout=True 的标志,而实际上我使用的是 2.8。

【讨论】:

    猜你喜欢
    • 2018-11-18
    • 2014-08-03
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 2014-04-19
    • 2014-06-15
    • 1970-01-01
    • 2015-11-18
    相关资源
    最近更新 更多