mongodb runtime_error ai_generated partial

MongoServerError:均衡器移动块失败:块 { ns: "test.users", min: { _id: 1 }, max: { _id: 100 } } 无法移动

MongoServerError: balancer failed to move chunk: chunk { ns: "test.users", min: { _id: 1 }, max: { _id: 100 } } could not be moved

ID: mongodb/balancer-failed-to-move-chunk

其他格式: JSON · Markdown 中文 · English
78%修复率
85%置信度
1证据数
2024-02-10首次发现

版本兼容性

版本状态引入弃用备注
mongodb-5.0 active
mongodb-6.0 active
mongodb-7.0 active

根因分析

均衡器无法移动块,因为目标分片存储不足或块大小超过最大块大小。

English

The balancer could not move a chunk because the target shard had insufficient storage or the chunk exceeded the maximum chunk size.

generic

官方文档

https://www.mongodb.com/docs/manual/core/sharding-balancer-administration/

解决方案

  1. Check target shard disk usage with db.adminCommand({ listShards: 1 }) and add more shards or free up space on the target.
  2. Reduce chunk size temporarily via mongos config: use sh.enableAutoSplit() and sh.setBalancerState(true) with smaller chunkSize (e.g., 64MB) to split large chunks before migration.
  3. Manually move the chunk using sh.moveChunk() with a specific shard key range to force migration during low traffic.

无效尝试

常见但无效的做法:

  1. 50% 失败

    Increasing chunkSize to a very large value can cause uneven data distribution and balancer inefficiency.

  2. 50% 失败

    Disabling the balancer entirely stops automatic data redistribution, leading to uneven shard loads.

  3. 50% 失败

    Manually splitting chunks without considering data distribution can create many small chunks that strain the balancer.