I am trying sharding in MongoDB. I am working with

  • 1 config server
  • 1 Query router
  • 2 shards

I tried hash based sharding. The data is getting partitioned but sharding is not successful. In one shard some documents are present but in another shard the number of documents is zero. In logging I could see the warning:

warning: moveChunkCmd deleted data already in chunk

I can get a point that the data is lost while the chunk is migrating from one shard to another shard. But I am not sure how to avoid the data lost while the chunk is migrating.

  • When chunks are moved, they meta data points to the new shard only after a successful chunk migration took place. Did you move the chunks manually? – Markus W Mahlberg Nov 5 '14 at 10:08
  • No. I didn't move the chunks manually. – Priya Nov 5 '14 at 11:23
  • How many documents you have total? – Antonios Nov 5 '14 at 19:28
  • The total documents was around 4000. The size of that will be around 124 MB – Priya Nov 6 '14 at 4:01

The data is not being lost - that message means that when the migration was attempted from the source shard to the target, there was already data present that matched the chunk range, which was then deleted (this is what is supposed to happen, which is why that is not an error, but a warning). Since you are starting from scratch, it implies that you have data present in that collection, in that range before any migrations are attempted.

This condition can happen occasionally on sharded clusters that have been running for a while (and chunks move around), hence the warning rather than an error. However in this case it suggests that this was not a clean database on at least one shard when you began. There are either some steps missing from this description, or possibly you failed to clean up properly after a previous attempt.

In any case, I would suggest posting the full procedure that brought this about - I have tested hashed sharding with 2 shards, 1 config server and 1 mongos many, many times (occasionally live in front of others as part of a demo) and never caused this to happen with normal operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.