{
  "id": "database/mongodb-replica-set-no-primary",
  "signature": "MongoServerError: no primary found in replica set, cannot perform operation",
  "signature_zh": "MongoServerError：在副本集中未找到主节点，无法执行操作",
  "regex": "no primary found in replica set",
  "domain": "database",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "No member of the MongoDB replica set is in PRIMARY state, often due to an election failure, network partition, or majority loss.",
  "root_cause_type": "generic",
  "root_cause_zh": "MongoDB副本集中没有成员处于PRIMARY状态，通常是由于选举失败、网络分区或多数节点丢失。",
  "versions": [
    {
      "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"
    },
    {
      "version": "MongoDB 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Restart all MongoDB instances in the replica set simultaneously",
      "why_fails": "Restarting all nodes at once can cause a complete outage and may not resolve underlying election issues; a step restart is safer.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Forcibly step down a secondary with rs.stepDown() to trigger election",
      "why_fails": "If no qualified secondary exists (e.g., all are behind in replication), stepDown() will not elect a new primary.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check replica set status: rs.status(); identify which nodes are up and their states. If a node is SECONDARY but has high replication lag, wait for it to catch up.",
      "success_rate": 0.8,
      "how": "Check replica set status: rs.status(); identify which nodes are up and their states. If a node is SECONDARY but has high replication lag, wait for it to catch up.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Force re-election by connecting to a secondary and running: rs.reconfigForPSASet(); or manually reconfigure with rs.reconfig() to set a new primary.",
      "success_rate": 0.75,
      "how": "Force re-election by connecting to a secondary and running: rs.reconfigForPSASet(); or manually reconfigure with rs.reconfig() to set a new primary.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If a node is in ROLLBACK state, allow rollback to complete: use rs.stepDown() on the former primary to let the rollback finish.",
      "success_rate": 0.85,
      "how": "If a node is in ROLLBACK state, allow rollback to complete: use rs.stepDown() on the former primary to let the rollback finish.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check replica set status: rs.status(); identify which nodes are up and their states. If a node is SECONDARY but has high replication lag, wait for it to catch up.",
    "Force re-election by connecting to a secondary and running: rs.reconfigForPSASet(); or manually reconfigure with rs.reconfig() to set a new primary.",
    "If a node is in ROLLBACK state, allow rollback to complete: use rs.stepDown() on the former primary to let the rollback finish."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/reference/method/rs.status/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-05-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}