【问题标题】:MongoDB - MongoError: Resulting document after update is larger than 16777216MongoDB - MongoError:更新后的结果文档大于 16777216
【发布时间】:2017-08-16 16:20:54
【问题描述】:

我的 ExpressJS 应用程序出现此错误:

Error updating stream: MongoError: Resulting document after update is larger than 16777216
_http_server.js:192
    throw new RangeError(`Invalid status code: ${statusCode}`);

所以我假设我的文档已经超出了限制。

如何提高限​​额?

我从这个answer 得到这个link。但是如何在我的应用程序中使用它?我该如何开始?

我正在使用猫鼬来存储和检索我的数据。

有什么想法/提示吗?

这是我在猫鼬中的文档架构:

var mongoose = require("mongoose");
var mongoosePaginate = require('mongoose-paginate');

// Declare schema
var streadatamSchema = new mongoose.Schema({
    user_id: {
        type: String,
        required: true
    },
    title: {
        type: String,
        required: true
    },
    description: {
        type: String,
        required: true
    },
    data: {
        type: Object
    },
    entries_number: {
        type: Number,
        default: 0
    },
    last_entry_at: {
        type: Date
    },
    created_at: {
        type: Date,
        default: Date.now,
        index: 1 // Note 1
    },
});

streamSchema.plugin(mongoosePaginate);

// Export schema
// Model.paginate()
mongoose.model("Stream", streamSchema);

我认为是data 字段现在包含太多数据。

【问题讨论】:

    标签: node.js mongodb express mongoose


    【解决方案1】:

    所以我假设我的文档已经超出了限制。

    如何提高限​​额?

    Mongo 中的大小限制是hardcoded in the source code:

    /* Note the limit here is rather arbitrary and is simply a standard. generally the code works
       with any object that fits in ram.
       Also note that the server has some basic checks to enforce this limit but those checks are not exhaustive
       for example need to check for size too big after
         update $push (append) operation
         various db.eval() type operations
    */
    const int BSONObjMaxUserSize = 16 * 1024 * 1024;
    
    /*
       Sometimes we need objects slightly larger - an object in the replication local.oplog
       is slightly larger than a user object for example.
    */
    const int BSONObjMaxInternalSize = BSONObjMaxUserSize + ( 16 * 1024 );
    
    const int BufferMaxSize = 64 * 1024 * 1024;
    

    更改它的唯一方法是更改​​源代码并从源代码构建您自己的 Mongo 版本。

    【讨论】:

    • @rsp 如何从源代码构建我自己的 Mongo 版本?
    • 这个问题解决了吗,还是我们仍然需要从源代码构建 mongo ?
    猜你喜欢
    • 2021-04-21
    • 2020-11-19
    • 1970-01-01
    • 2012-12-13
    • 2015-07-17
    • 2017-08-22
    • 1970-01-01
    • 2020-05-06
    • 2016-06-28
    相关资源
    最近更新 更多