{
  "id": "database/mongodb-cannot-update-system-index",
  "signature": "MongoServerError: Cannot update system index 'system.indexes'",
  "signature_zh": "MongoServerError: 无法更新系统索引 'system.indexes'",
  "regex": "MongoServerError: Cannot update system index",
  "domain": "database",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "An attempt was made to directly modify a system collection (like system.indexes) using a write operation, which is forbidden in MongoDB for security and consistency reasons.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试使用写操作直接修改系统集合（如 system.indexes），MongoDB 出于安全性和一致性原因禁止这样做。",
  "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": "Trying to drop and recreate the system.indexes collection",
      "why_fails": "MongoDB prevents dropping system collections; this operation will fail with a similar error.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using db.runCommand({collMod: 'system.indexes', ...})",
      "why_fails": "collMod is not supported for system collections; MongoDB returns an error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use the proper MongoDB command to manage indexes, such as createIndex() or dropIndex(), which handle system collection updates internally:\ndb.myCollection.createIndex({ field: 1 })",
      "success_rate": 0.95,
      "how": "Use the proper MongoDB command to manage indexes, such as createIndex() or dropIndex(), which handle system collection updates internally:\ndb.myCollection.createIndex({ field: 1 })",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need to modify system collection behavior, use documented features like the 'system.profile' collection via db.setProfilingLevel() instead of direct writes.",
      "success_rate": 0.85,
      "how": "If you need to modify system collection behavior, use documented features like the 'system.profile' collection via db.setProfilingLevel() instead of direct writes.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use the proper MongoDB command to manage indexes, such as createIndex() or dropIndex(), which handle system collection updates internally:\ndb.myCollection.createIndex({ field: 1 })",
    "If you need to modify system collection behavior, use documented features like the 'system.profile' collection via db.setProfilingLevel() instead of direct writes."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/reference/method/db.createCollection/#std-label-create-collection-system-collections",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}