Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pymongo: "OperationFailure: database error: error querying server"

We're occasionally getting the following error when doing queries:

OperationFailure: database error: error querying server

There is no specific query causing this, and when repeating the process things work. Has anybody else seen this error?

Our setup is a cluster of Ubuntu VMs on Amazon EC2, we're using Python 2.7.3 and pymongo v2.3. We're also using Mongoengine, however we still get this exception from non-Mongoengine code.

like image 201
robbrit Avatar asked Feb 14 '13 14:02

robbrit


1 Answers

To those discovering this question:

We were never able to fully diagnose the problem with this, our hunch is that the database connection tends to fail every once in a while for whatever reason. From our research into distributed computing, this is a common problem and needs to be handled explicitly.

In the end, we adapted our system to become robust to DB connection failures by catching OperationFailure exceptions along with similar ones and re-establishing the database connection. This resolved the problem along with a number of similar ones we were having.

like image 125
robbrit Avatar answered Oct 01 '22 14:10

robbrit