database
data_error
ai_generated
true
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
85%Fix Rate
88%Confidence
1Evidence
2023-06-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| MongoDB 6.0.10 | active | — | — | — |
| MongoDB 7.0.4 | active | — | — | — |
| MongoDB 5.0.24 | active | — | — | — |
Root Cause
The document being inserted or updated exceeds MongoDB's 16MB BSON document size limit.
generic中文
插入或更新的文档超过了 MongoDB 的 16MB BSON 文档大小限制。
Official Documentation
https://www.mongodb.com/docs/manual/reference/limits/#mongodb-limit-BSON-Document-SizeWorkarounds
-
85% success 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`
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`
-
80% success Restructure the document to remove large arrays or subdocuments, storing them in separate collections with references.
Restructure the document to remove large arrays or subdocuments, storing them in separate collections with references.
中文步骤
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`
Restructure the document to remove large arrays or subdocuments, storing them in separate collections with references.
Dead Ends
Common approaches that don't work:
-
100% fail
MongoDB's 16MB limit is hardcoded and cannot be changed; no such startup parameter exists.
-
90% fail
Compression must be done at the storage engine level (WiredTiger), not by the application; the BSON size check occurs before storage.