Encontrar jumbo chunks, dividirlos y borrar la marca
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 } })Qué hace
Lista los chunks marcados como jumbo porque el balancer no pudo moverlos, divide los que pueden dividirse y borra la marca jumbo; muestra cómo refinar la shard key para chunks enormes de un solo valor.
Cuándo usarlo
Cuando un shard sigue siendo claramente mayor que los demás, aparece jumbo en la salida de sh.status() o el balancer reporta errores de migración.
Precaución
Un chunk cuyos documentos comparten todos el mismo valor de shard key no puede dividirse; la única solución duradera es cambiar la shard key con refineCollectionShardKey o reshardCollection. refineCollectionShardKey requiere que exista de antemano un índice que soporte la nueva clave. Borrar la marca jumbo sin dividir hace que el balancer reintente el mismo chunk y vuelva a fallar.