# MongoServerError: Balancer round failed: chunk migration failed for namespace test.users, reason: cannot move chunk because the source shard has no primary

- **ID:** `mongodb/balancer-round-failed`
- **Domain:** mongodb
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

The balancer attempted to move a chunk from a shard that lost its primary replica due to network partition or replica set election failure.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 5.0 | active | — | — |
| MongoDB 6.0 | active | — | — |
| MongoDB 7.0 | active | — | — |

## Workarounds

1. **Restore primary on the source shard by forcing an election: rs.stepDown() on the current primary and rs.reconfig() with appropriate priority settings, then wait for the new primary to be elected.** (85% success)
   ```
   Restore primary on the source shard by forcing an election: rs.stepDown() on the current primary and rs.reconfig() with appropriate priority settings, then wait for the new primary to be elected.
   ```
2. **If the shard is permanently unavailable, remove it from the cluster: db.adminCommand({removeShard: 'shardName'}) after draining its chunks to other shards.** (80% success)
   ```
   If the shard is permanently unavailable, remove it from the cluster: db.adminCommand({removeShard: 'shardName'}) after draining its chunks to other shards.
   ```

## Dead Ends

- **** — Manually moving the chunk with moveChunk command fails with same error because the shard is still in recovery. (95% fail)
- **** — Disabling the balancer (sh.stopBalancer()) stops the error but prevents data distribution, leading to uneven shard loads. (60% fail)
