Mongodb shard balancing failed

mongodbsharding

Data balancing fails on Mongo cluster with 1 mongos and 3 mongod instances. All the data for the collection fs.chunks stays in the same shard with the following error.

Env: Ubuntu- AWS m3.large,

error from sh.status()

6 : Failed with error 'could not acquire collection lock for test.fs.chunks to migrate chunk [{ : MinKey },{ : MaxKey }) :: caused by :: Lock for migrating chunk [{ : MinKey }, { : MaxKey }) in test.fs.chunks is taken.', from shard0001 to shard0000
3826 : Failed with error 'moveChunk failed to engage TO-shard in the data transfer: can't accept new chunks because there are still 7 deletes from previous migration', from shard0000 to shard0001
7655 : Failed with error 'moveChunk failed to engage TO-shard in the data transfer: can't accept new chunks because there are still 4 deletes from previous migration', from shard0001 to shard0000

Best Answer

As I am able to see the chunks error such as

3826 : Failed with error 'moveChunk failed to engage TO-shard in the data transfer: can't accept new chunks because there are still 7 deletes from previous migration', from shard0000 to shard0001 7655 : Failed with error 'moveChunk failed to engage TO-shard in the data transfer: can't accept new chunks because there are still 4 deletes from previous migration', from shard0001 to shard0000

As Asya Kamsky google groups documentation here When importing a large amount of data it is always preferable to pre-split the collection and distribute chunks evenly across the shards and disable balancer before starting the data load. Otherwise you will see the migrations and new data load compete for the same resources, reducing the performance of both.

Yes, you should/can re-enable the balancer after the import is done. But of course it's better to presplit/pre-balance as described here.

For further your ref here