{
  "id": "mongodb/replica-set-election-failed",
  "signature": "MongoServerError: ReplicaSetMonitor: election failed for set rs0",
  "signature_zh": "MongoServerError: ReplicaSetMonitor: 副本集 rs0 选举失败",
  "regex": "ReplicaSetMonitor: election failed for set [\\w-]+",
  "domain": "mongodb",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The replica set election failed due to a tie or network partition preventing a majority of nodes from agreeing on a primary.",
  "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": "Restarting nodes doesn't resolve the underlying voting deadlock; it may reset timers but the same tie condition persists.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "rs.stepDown() only triggers a new election without addressing the root cause of the tie.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding more nodes doesn't automatically break ties; it requires adjusting electionTimeoutMillis or priority settings.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Force a new election by stepping down the current primary with a specific timeout: rs.stepDown(60, { force: true })",
      "success_rate": 0.85,
      "how": "Force a new election by stepping down the current primary with a specific timeout: rs.stepDown(60, { force: true })",
      "condition": "",
      "sources": []
    },
    {
      "action": "Temporarily increase electionTimeoutMillis on all nodes to allow more time for consensus: cfg = rs.conf(); cfg.settings.electionTimeoutMillis = 15000; rs.reconfig(cfg)",
      "success_rate": 0.9,
      "how": "Temporarily increase electionTimeoutMillis on all nodes to allow more time for consensus: cfg = rs.conf(); cfg.settings.electionTimeoutMillis = 15000; rs.reconfig(cfg)",
      "condition": "",
      "sources": []
    },
    {
      "action": "If a tie persists, manually set a node's priority to 0 to remove it from contention, then reconfig: cfg = rs.conf(); cfg.members[1].priority = 0; rs.reconfig(cfg)",
      "success_rate": 0.8,
      "how": "If a tie persists, manually set a node's priority to 0 to remove it from contention, then reconfig: cfg = rs.conf(); cfg.members[1].priority = 0; rs.reconfig(cfg)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Force a new election by stepping down the current primary with a specific timeout: rs.stepDown(60, { force: true })",
    "Temporarily increase electionTimeoutMillis on all nodes to allow more time for consensus: cfg = rs.conf(); cfg.settings.electionTimeoutMillis = 15000; rs.reconfig(cfg)",
    "If a tie persists, manually set a node's priority to 0 to remove it from contention, then reconfig: cfg = rs.conf(); cfg.members[1].priority = 0; rs.reconfig(cfg)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/reference/replica-configuration/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}