database data_error ai_generated true

MongoServerError: BSONObj 大小:17825792 (0x1100000) 无效。大小必须在 0 到 16793600(16MB) 之间。第一个元素:_id: ObjectId('...')

MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: ObjectId('...')

ID: database/mongodb-document-too-large

其他格式: JSON · Markdown 中文 · English
85%修复率
88%置信度
1证据数
2023-06-20首次发现

版本兼容性

版本状态引入弃用备注
MongoDB 6.0.10 active
MongoDB 7.0.4 active
MongoDB 5.0.24 active

根因分析

插入或更新的文档超过了 MongoDB 的 16MB BSON 文档大小限制。

English

The document being inserted or updated exceeds MongoDB's 16MB BSON document size limit.

generic

官方文档

https://www.mongodb.com/docs/manual/reference/limits/#mongodb-limit-BSON-Document-Size

解决方案

  1. Use GridFS to store large documents. Split the document into chunks and store them in fs.files and fs.chunks collections. Example: `mongofiles put large_document.json`
  2. Restructure the document to remove large arrays or subdocuments, storing them in separate collections with references.

无效尝试

常见但无效的做法:

  1. 100% 失败

    MongoDB's 16MB limit is hardcoded and cannot be changed; no such startup parameter exists.

  2. 90% 失败

    Compression must be done at the storage engine level (WiredTiger), not by the application; the BSON size check occurs before storage.