{
  "id": "mongodb/balancer-round-failed",
  "signature": "MongoServerError: Balancer round failed: chunk migration failed for namespace test.users, reason: cannot move chunk because the source shard has no primary",
  "signature_zh": "MongoServerError: 均衡器轮次失败：命名空间 test.users 的块迁移失败，原因：源分片没有主节点",
  "regex": "Balancer round failed: chunk migration failed for namespace .+, reason: cannot move chunk because the source shard has no primary",
  "domain": "mongodb",
  "category": "runtime_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "均衡器尝试从因网络分区或副本集选举失败而失去主副本的分片移动块。",
  "versions": [
    {
      "version": "MongoDB 5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Manually moving the chunk with moveChunk command fails with same error because the shard is still in recovery.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling the balancer (sh.stopBalancer()) stops the error but prevents data distribution, leading to uneven shard loads.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.85,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the shard is permanently unavailable, remove it from the cluster: db.adminCommand({removeShard: 'shardName'}) after draining its chunks to other shards.",
      "success_rate": 0.8,
      "how": "If the shard is permanently unavailable, remove it from the cluster: db.adminCommand({removeShard: 'shardName'}) after draining its chunks to other shards.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过强制选举恢复源分片的主节点：在当前主节点上执行 rs.stepDown()，然后使用适当的优先级设置执行 rs.reconfig()，等待新主节点选举完成。",
    "如果分片永久不可用，则将其从集群中移除：在将其块排干到其他分片后，执行 db.adminCommand({removeShard: 'shardName'})。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/core/sharding-balancer-administration/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.82,
  "resolvable": "partial",
  "first_seen": "2025-03-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}