# MongoServerError：均衡器往返时间超过30秒：块迁移超时

- **ID:** `mongodb/balancer-round-trip-timeout`
- **领域:** mongodb
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

由于网络延迟或源分片过载，分片间的块迁移失败，超过了30秒的往返时间阈值。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| mongodb 6.0 | active | — | — |
| mongodb 7.0 | active | — | — |
| mongodb 8.0 | active | — | — |

## 解决方案

1. ```
   Temporarily disable the balancer to allow pending migrations to complete: `sh.stopBalancer(10000)` then re-enable after monitoring network latency between shards.
   ```
2. ```
   Increase chunk size to reduce migration frequency: `db.adminCommand({ setClusterParameter: { chunkSize: 128 } })` and ensure source shard has sufficient I/O capacity.
   ```
3. ```
   Use `db.adminCommand({ moveChunk: 'mydb.mycoll', find: { shardKey: value }, to: 'targetShard', maxTimeMS: 60000 })` to manually migrate chunks with a longer timeout after verifying network health.
   ```

## 无效尝试

- **** — The timeout is caused by underlying network or resource issues, not stale balancer state; restarting only delays recovery and may lose migration progress. (90% 失败率)
- **** — The round-trip timeout is a hard-coded balancer limit, not a client-side query timeout; adjusting maxTimeMS does not affect internal balancer logic. (95% 失败率)
- **** — Stopping all chunk migrations leads to data imbalance, reduced query performance, and eventual cluster instability. (80% 失败率)
