Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OperationFailure invalid cursor id #7

Closed
abrimo opened this issue Jul 3, 2012 · 4 comments
Closed

OperationFailure invalid cursor id #7

abrimo opened this issue Jul 3, 2012 · 4 comments

Comments

@abrimo
Copy link

abrimo commented Jul 3, 2012

It looks like the cursor needs to be refreshed or this exception should be caught at some stage instead of bubbling up to the application.

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "....py", line 17, in notificationGrouping
    for notification in Notification.objects.order_by( '_id' ):
  File "...python2.7/site-packages/mongorm-0.1-py2.7.egg/mongorm/queryset/QuerySet.py", line 174, in __iter__
    for i,item in enumerate(self._savedItems):
  File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 655, in next
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 631, in _refresh
    limit, self.__id))
  File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 587, in __send_message
    self.__tz_aware)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 94, in _unpack_response
    cursor_id)
OperationFailure: cursor id '1160188852557533216' not valid at server
@dougallj
Copy link
Contributor

dougallj commented Jul 3, 2012

Might be easiest to pass through the pymongo Collection.find's timeout keyword argument for long-expected-runtime queries. Do we close these safely?

I'm not sure if it's possible to keep re-create a cursor without knowing the database state, although perhaps if we know the number of returned values we can just slice by that. This would cause duplicates though, where the database has been modified during the evidently long-running query and that would be a far greater concern. Mongo is already kind enough to return duplicates when iterating though and modifying unsorted cursors.

If it were possible for mongorm to do 100% reliable cleanup (even when killed, etc), we could make all queries not timeout, but this seems like small bugs could kill the database server, although it's not that much worse than memory management in C.

@abrimo
Copy link
Author

abrimo commented Jul 3, 2012

Timeout sounds like it would work. I'm not too familiar with mongorm/db - would all the connections get closed when the python interpreter (where I'm running this command) exits?

@theojulienne
Copy link
Contributor

Yes, mongo performs cleanups. The most mongorm can do really is allow setting the timeout value and/or re-raise this exception as a mongorm exception.

@theojulienne
Copy link
Contributor

Closing since the above 2 issues are the best you can expect from a database abstraction layer.

johnnyg referenced this issue in johnnyg/mongorm Sep 11, 2012
Fix in operator not working with references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants