MongoDB Cursor freezes

While working on a local copy of a larger project database, the mongodb cursor seems to freeze for most queries. In particular, I work with PyMongo, but even a simple count() on the collection hangs (so the problem is not a python problem).

An iteration of the cursor until it gets stuck shows that it always happens at one point (i.e. for the same query) - after which it just hangs. An attempt at cursor.alive shows that he is really alive and well.

Dropping and restoring indices also does not help.

Launching mongodb version 2.6.4. and PyMongo version 3.02. Db contains about 1.2M elements.

Does anyone experience something like this? Thanks!

+6
source share
1 answer

I work with big data, and in my practice there have been such cases, but the reasons were different.

Here are the reasons why you can hang the MongoDB cursor:

  • when the machine is very busy or not good enough for big data like this
  • when calling the sort() method for properties that do not have indexes
  • when the size of each document is too large and limit/batchSize not set upon request.

I could solve this problem by adding batchSize to such requests:

 db.players.find().batchSize(50).limt(10) 

You can find more about MongoDB package size here.

-1
source

Source: https://habr.com/ru/post/987993/


All Articles