Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pymongo AssertionError: ids don't match

I use:

  • MongoDB 1.6.5
  • Pymongo 1.9
  • Python 2.6.6

I have 3 types of daemons. 1st load data from web, 2nd analyze it and save result, and 3rd group result. All of them working with Mongodb. At some time 3rd daemon throws many exceptions like this(mostly when there are big amount of data in DB):

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/gevent-0.13.1-py2.6-linux-x86_64.egg/gevent/greenlet.py", line 405, in run
    result = self._run(*self.args, **self.kwargs)
  File "/data/www/spider/daemon/scripts/mainconverter.py", line 72, in work
    for item in res:
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 601, in next
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 564, in _refresh
    self.__query_spec(), self.__fields))
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 521, in __send_message
    **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 743, in _send_message_with_response
    return self.__send_and_receive(message, sock)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 724, in __send_and_receive
    return self.__receive_message_on_socket(1, request_id, sock)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 714, in __receive_message_on_socket
    struct.unpack("<i", header[8:12])[0])
AssertionError: ids don't match -561338340 0
<Greenlet at 0x2baa628: <bound method Worker.work of <scripts.mainconverter.Worker object at 0x2ba8450>>> failed with AssertionError

Can anyone tell what cause this exeption and how to fix this.

Thanks.

like image 857
Andrey Nikishaev Avatar asked Oct 14 '22 17:10

Andrey Nikishaev


1 Answers

This is likely a threading problem related to how you are using worker threads with gevent coroutines. It seems like the pymongo connection object is reading a response for a request it didn't make.

like image 185
Bernie Hackett Avatar answered Nov 03 '22 06:11

Bernie Hackett