{
  "id": "mongodb/sharded-collection-chunk-split-error",
  "signature": "MongoServerError: chunk split failed: could not find the shard key value for document",
  "signature_zh": "MongoServerError: 块拆分失败：找不到文档的分片键值",
  "regex": "chunk split failed: could not find the shard key value for document",
  "domain": "mongodb",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "During chunk migration or splitting, the balancer or mongos cannot determine the shard key value for one or more documents, often due to missing shard key fields or null values.",
  "root_cause_type": "generic",
  "root_cause_zh": "在块迁移或拆分过程中，均衡器或 mongos 无法确定一个或多个文档的分片键值，通常是由于缺少分片键字段或值为 null。",
  "versions": [
    {
      "version": "mongodb-4.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-4.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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": "This corrupts the sharding metadata and can cause data loss or cluster instability.",
      "fail_rate": 0.2,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The balancer is not the root cause; the documents with missing shard keys remain, so any future split will fail.",
      "fail_rate": 0.15,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If the shard key is compound, adding a single field may not resolve the issue and could violate shard key constraints.",
      "fail_rate": 0.25,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Find documents with missing or null shard key fields using a query like `db.collection.find({shardKeyField:{$exists:false}})` and update them with a valid value. Example: `db.collection.updateMany({shardKeyField:{$exists:false}},{$set:{shardKeyField:0}})`",
      "success_rate": 0.85,
      "how": "Find documents with missing or null shard key fields using a query like `db.collection.find({shardKeyField:{$exists:false}})` and update them with a valid value. Example: `db.collection.updateMany({shardKeyField:{$exists:false}},{$set:{shardKeyField:0}})`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the shard key is compound, ensure all fields in the shard key exist and are non-null. Use `db.collection.find({$or:[{field1:{$exists:false}},{field2:{$exists:false}}]})` to identify problematic documents.",
      "success_rate": 0.8,
      "how": "If the shard key is compound, ensure all fields in the shard key exist and are non-null. Use `db.collection.find({$or:[{field1:{$exists:false}},{field2:{$exists:false}}]})` to identify problematic documents.",
      "condition": "",
      "sources": []
    },
    {
      "action": "As a last resort, export the collection, drop it, and re-import with proper shard key values. Example: `mongodump --collection mycollection; db.mycollection.drop(); sh.shardCollection('mydb.mycollection',{shardKey:1}); mongorestore --collection mycollection`",
      "success_rate": 0.7,
      "how": "As a last resort, export the collection, drop it, and re-import with proper shard key values. Example: `mongodump --collection mycollection; db.mycollection.drop(); sh.shardCollection('mydb.mycollection',{shardKey:1}); mongorestore --collection mycollection`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Find documents with missing or null shard key fields using a query like `db.collection.find({shardKeyField:{$exists:false}})` and update them with a valid value. Example: `db.collection.updateMany({shardKeyField:{$exists:false}},{$set:{shardKeyField:0}})`",
    "If the shard key is compound, ensure all fields in the shard key exist and are non-null. Use `db.collection.find({$or:[{field1:{$exists:false}},{field2:{$exists:false}}]})` to identify problematic documents.",
    "As a last resort, export the collection, drop it, and re-import with proper shard key values. Example: `mongodump --collection mycollection; db.mycollection.drop(); sh.shardCollection('mydb.mycollection',{shardKey:1}); mongorestore --collection mycollection`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/core/sharding-data-partitioning/",
  "official_doc_section": null,
  "error_code": "60",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.78,
  "resolvable": "partial",
  "first_seen": "2023-11-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}