Encontrar jumbo chunks, dividi-los e limpar a flag
MongoDBShardingComando
// Chunks flagged as jumbo (5.0+ config.chunks links to the collection by uuid):
const uuid = db.getSiblingDB("config").collections.findOne({ _id: "shop.musteri" }).uuid;
db.getSiblingDB("config").chunks.find({ uuid: uuid, jumbo: true }, { min: 1, max: 1, shard: 1 })
// If the chunk can be split, split it at the median:
sh.splitFind("shop.musteri", { musteriId: 1000 })
// Last resort for an indivisible chunk, clear the flag manually (a successful split already clears it):
db.adminCommand({ clearJumboFlag: "shop.musteri", find: { musteriId: 1000 } })
// If a single key value is too large, refine the key (4.4+):
db.adminCommand({ refineCollectionShardKey: "shop.musteri", key: { musteriId: 1, siparisId: 1 } })O que faz
Lista os chunks marcados como jumbo porque o balancer não conseguiu movê-los, divide os que podem ser divididos e limpa a flag jumbo; mostra como refinar a shard key para chunks enormes de valor único.
Quando usar
Quando um shard fica visivelmente maior que os outros, jumbo aparece na saída de sh.status() ou o balancer reporta erros de migração.
Atenção
Um chunk cujos documentos compartilham todos o mesmo valor de shard key não pode ser dividido; a única correção duradoura é mudar a shard key com refineCollectionShardKey ou reshardCollection. refineCollectionShardKey exige que um índice de suporte para a nova chave exista previamente. Limpar a flag jumbo sem dividir faz o balancer tentar o mesmo chunk de novo e falhar outra vez.