Mongodb sharding: Chunk split failed with Hashed Shard Key

1.1k views Asked by At

I am trying to split few jumbo chunks in mongodb sharded cluster sharded using hashed shard key: {group_id:"hashed"}.

I used the following command from mongodb docs to split these jumbo chunks:

db.runCommand( { split: "test.people",
                  bounds : [ { group_id: NumberLong("-5838464104018346494") },
                             { group_id: NumberLong("-5557153028469814163") }
             ] } )

But getting following error:

{ "cause" : { }, "ok" : 0, "errmsg" : "split failed" }.

What is the possible cause of this failure? The shard key group_id has cardinality 26231 against total 4521157 documents.

Have checked this disussion but unable to find the cause.

P.S : The group_id is ObjectId.

1

There are 1 answers

0
Maxime Beugnet On

Your cardinality is way too small. One chunk will split automatically when he reaches 64mb.

Currently, with a cardinality of 26231, your collection can't be bigger than 26231*64mb maximum without jumbo chunks... And you will probably have problems a long time before that unless you have a perfect distribution.

In your case, you don't have any value of group_id resulting in a hashed value between NumberLong("-5838464104018346494") and NumberLong("-5557153028469814163")...

So you can't split it because your cardinality is too small.

To sum up, you need a better shard key immediately which means mongodump everything and then mongorestore with the new shard key.