{
  "id": "database/mongodb-bson-size-exceeded",
  "signature": "MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB) First element",
  "signature_zh": "MongoServerError：BSONObj 大小：17825792 (0x1100000) 无效。大小必须在 0 到 16793600(16MB) 之间。第一个元素",
  "regex": "MongoServerError: BSONObj size: \\d+ \\(0x[0-9a-fA-F]+\\) is invalid. Size must be between 0 and 16793600\\(16MB\\)",
  "domain": "database",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A BSON document exceeds MongoDB's 16MB document size limit, typically caused by inserting or updating a document with large arrays, nested data, or binary fields like GridFS chunks that exceed the maximum allowed size.",
  "root_cause_type": "generic",
  "root_cause_zh": "BSON 文档超过 MongoDB 的 16MB 文档大小限制，通常是由于插入或更新包含大型数组、嵌套数据或二进制字段（如 GridFS 块）的文档，超出最大允许大小。",
  "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": "Increasing the BSON document size limit via a configuration parameter like 'maxBsonObjectSize'",
      "why_fails": "MongoDB does not allow changing the 16MB limit; it is a hard-coded limit in the server. Attempting to set such a parameter will be ignored or cause an error.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Splitting the document into multiple smaller documents but keeping the same structure without using references",
      "why_fails": "If the application logic expects a single document, splitting may break queries; also, if the data is inherently large (e.g., a large file), splitting into separate documents may not be appropriate without using GridFS.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use GridFS for large files: store the large data as a GridFS file instead of embedding it in a document. Example: mongofiles put large_file.bin --db mydb",
      "success_rate": 0.95,
      "how": "Use GridFS for large files: store the large data as a GridFS file instead of embedding it in a document. Example: mongofiles put large_file.bin --db mydb",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce document size by removing unnecessary fields, splitting arrays into separate collections, or using references (e.g., store large arrays in a subcollection and link via _id).",
      "success_rate": 0.85,
      "how": "Reduce document size by removing unnecessary fields, splitting arrays into separate collections, or using references (e.g., store large arrays in a subcollection and link via _id).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 GridFS 存储大文件：将大型数据作为 GridFS 文件存储，而不是嵌入到文档中。例如：mongofiles put large_file.bin --db mydb",
    "通过删除不必要的字段、将数组拆分为单独的集合或使用引用（例如，将大型数组存储在子集合中并通过 _id 链接）来减小文档大小。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/reference/limits/#mongodb-limit-BSON-Document-Size",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-09-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}