I have a staging mongodb 4.0.19 sharded cluster with 2 replica set shards . I want to remove one shard. I followed the documentation: https://docs.mongodb.com/v4.0/tutorial/remove-shards-from-cluster/index.html and used removeShard command. But one chunk cannot be moved: the config.system.sessions chunk. I have the following error:

2020-07-30T09:21:07.330+0200 W SHARDING [conn21] Chunk move failed :: caused by :: OperationFailed: Data transfer error: migrate failed: InvalidUUID: Cannot create collection config.system.sessions because we already have an identically named collection with UUID b788097c-5ba1-464c-9064-0b7faed5c196, which differs from the donor's UUID 22588e86-20a2-4cdf-a70e-803fbd7b3e5a. Manually drop the collection on this shard if it contains data from a previous incarnation of config.system.sessions

This prevents draining chunks to finish. Is there any way to drop that collection or to force removeShard command to finish ?

2 Answers 2


If you login directly to that shard (and not mongos), you can drop that collection. After you have logged in to that shard, you can check with db.collection.find() command that there is no data what you want to save, before you drop it.


If you accept downtime, then -> take a dump of the whole collection, and drop the collection from mongos, then again create the collection from mongos, and restore whole data. Those data will remain in a primary shard, and not distributed. Go to config db -> db.collections.find() -> you will find the collection name marked dropped, mongo will never distribute its data.

If you not accept downtime then follow this link. https://docs.mongodb.com/v4.0/tutorial/remove-shards-from-cluster/index.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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