[SERVER-19477] MapReduce Tasks is not executed because of "BufBuilder attempted to grow() to 134217728 bytes, past the 64MB limit" Created: 17/Jul/15  Updated: 09/Jun/16  Resolved: 03/Oct/15

Status: Closed
Project: Core Server
Component/s: MapReduce
Affects Version/s: 2.6.9
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Timo Mika Gläßer Assignee: Sam Kleinman (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

I can share a script on request. However the database I am running this on: I can't share. I can demonstrate this via screen sharing though.

Sprint: Build 8 08/31/15
Participants:

 Description   

The error is the following and happens either during the MAP or the REDUCE steps none of which should be dealing with a lot of data inside the function call.

#######@#######:~$ mongo ####### /######/_scripts/reports/05_update_missing_report_data.js
MongoDB shell version: 2.4.9
connecting to: ########
Mapping Accounts
Done Mapping Accounts
Mapping Phones

Thu Jul 16 20:09:04.328 Assertion: 13548:BufBuilder attempted to grow() to 134217728 bytes, past the 64MB limit.
0x5638a6 0x52d3cc 0x473139 0x5176ca 0x518111 0x5184a6 0x517550 0x518111 0x5184a6 0x517550 0x518111 0x5184a6 0x52779b 0x5172de 0xff41a341039
mongo(_ZN5mongo15printStackTraceERSo+0x26) [0x5638a6]
mongo(_ZN5mongo11msgassertedEiPKc+0x9c) [0x52d3cc]
mongo(_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi+0xb9) [0x473139]
mongo(_ZN5mongo7V8Scope15v8ToMongoObjectERNS_14BSONObjBuilderERKNS_10StringDataEN2v86HandleINS6_5ValueEEEiPNS_7BSONObjE+0x29a) [0x5176ca]
mongo(_ZN5mongo7V8Scope16v8ToMongoElementERNS_14BSONObjBuilderERKNS_10StringDataEN2v86HandleINS6_5ValueEEEiPNS_7BSONObjE+0x721) [0x518111]
mongo(_ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi+0x176) [0x5184a6]
mongo(_ZN5mongo7V8Scope15v8ToMongoObjectERNS_14BSONObjBuilderERKNS_10StringDataEN2v86HandleINS6_5ValueEEEiPNS_7BSONObjE+0x120) [0x517550]
mongo(_ZN5mongo7V8Scope16v8ToMongoElementERNS_14BSONObjBuilderERKNS_10StringDataEN2v86HandleINS6_5ValueEEEiPNS_7BSONObjE+0x721) [0x518111]
mongo(_ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi+0x176) [0x5184a6]
mongo(_ZN5mongo7V8Scope15v8ToMongoObjectERNS_14BSONObjBuilderERKNS_10StringDataEN2v86HandleINS6_5ValueEEEiPNS_7BSONObjE+0x120) [0x517550]
mongo(_ZN5mongo7V8Scope16v8ToMongoElementERNS_14BSONObjBuilderERKNS_10StringDataEN2v86HandleINS6_5ValueEEEiPNS_7BSONObjE+0x721) [0x518111]
mongo(_ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi+0x176) [0x5184a6]
mongo(_ZN5mongo9mongoFindEPNS_7V8ScopeERKN2v89ArgumentsE+0xdb) [0x52779b]
mongo(_ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE+0xbe) [0x5172de]
[0xff41a341039]
Thu Jul 16 20:09:04.333 Error: BufBuilder attempted to grow() to 134217728 bytes, past the 64MB limit. at src/mongo/shell/query.js:78
failed to load: /########/_scripts/reports/05_update_missing_report_data.js



 Comments   
Comment by Ramon Fernandez Marina [ 03/Oct/15 ]

klesh, we're closing this ticket as we haven't heard back from you in a while. If the issue persists after upgrading to a 2.6 shell (or 3.0 if you're upgrading your servers as well) feel free to post additional details in this ticket so we can investigate further.

Comment by Sam Kleinman (Inactive) [ 11/Sep/15 ]

Hello,

Sorry for the delay in getting back to you. I've attempted to reproduce this on the most recent stable release (3.0.6) and 2.6.9 with a 2.4.9 shell (and various combinations of these versions) without luck. It might be helpful to have an example document or the ability to generate some test data as part of the reproduction.

Additionally I'm interested in seeing if you've been able to try this operation with a version from the 3.0 branch: are you still seeing this issue on a more recent version of MongoDB?

Regards,
sam

Comment by Timo Mika Gläßer [ 04/Aug/15 ]

Hey Ramon, Sam,

we're using 2.6.9 the shell might still be running 2.4.9 but the
actual data bearing nodes are 2.6.9.

I have a attached the script to this comment that runs the map-reduce jobs.

Is there anything else I can help you with?

____

//region scope variables
var partners = {};
 
db.accounts.find({}).forEach(
    function(a) {
        partners[a._id.valueOf()] = a.partner;
    }
);
//endregion
 
 
//region Map-Reduce Accounts
 
var generateAccountsTuple = function() {
    return {
        'Accounts_Created': 0
    };
};
 
var mapAccounts = function() {
 
    var	me = this,
        dayTs = Math.floor(me.createdAt / (24 * 60 * 60 * 1000)) * (24 * 60 * 60 * 1000),
        tuple = generateAccountsTuple();
 
    tuple['Accounts_Created'] = 1;
 
    emit({DayTimestamp: dayTs, partner: me.partner}, tuple);
};
 
var reduceAccounts = function(key, values) {
 
    var tuple = generateAccountsTuple();
 
    for(var i = 0; i < values.length; i++) {
        for(var p in tuple) {
            tuple[p] += values[i][p];
        }
    }
 
    return tuple;
};
 
print('Mapping Accounts');
db.accounts.mapReduce(
    mapAccounts,
    reduceAccounts,
    {
        out: { replace: 'pre.by_reports.accounts' },
        scope : { generateAccountsTuple: generateAccountsTuple }
    }
);
print('Done Mapping Accounts');
 
//endregion
 
//region Map-Reduce Phones
 
var generatePhonesTuple = function() {
    return {
        'PINs_Created': 0,
        'PINs_Deleted': 0,
        'FreePhones_Created': 0,
        'FreePhones_Deleted': 0,
        'Phones_Created': 0,
        'Phones_Deleted': 0
    };
};
 
var mapPhones = function() {
 
    var	me = this,
        dayTs = Math.floor(me.createdAt / (24 * 60 * 60 * 1000)) * (24 * 60 * 60 * 1000),
        tuple = generatePhonesTuple(),
        pId = partners[me.acc.valueOf()];
 
    switch(me.type) {
        case 'pin':
            tuple['PINs_Created'] = 1;
            break;
 
        case 'twilio':
            if(me.isFree)
                tuple['FreePhones_Created'] = 1;
            else
                tuple['Phones_Created'] = 1;
 
            break;
 
        default:
            break;
    }
 
    emit({DayTimestamp: dayTs, partner: pId}, tuple);
 
    if(me.deletedAt) {
        var deletedTs = Math.floor(me.deletedAt / (24 * 60 * 60 * 1000)) * (24 * 60 * 60 * 1000);
 
        switch(me.type) {
            case 'pin':
                tuple['PINs_Deleted'] = 1;
                break;
 
            case 'twilio':
                if(me.isFree)
                    tuple['FreePhones_Deleted'] = 1;
                else
                    tuple['Phones_Deleted'] = 1;
 
                break;
 
            default:
                break;
        }
 
        emit({DayTimestamp: deletedTs, partner: pId}, tuple);
    }
};
 
var reducePhones = function(key, values) {
 
    var tuple = generatePhonesTuple();
 
    for(var i = 0; i < values.length; i++) {
        for(var p in tuple) {
            tuple[p] += values[i][p];
        }
    }
 
    return tuple;
};
 
print('Mapping Phones');
db.phones.mapReduce(
    mapPhones,
    reducePhones,
    {
        out: { replace: 'pre.by_reports.phones' },
        query: {type: {$in: ['pin', 'twilio']}},
        scope : { generatePhonesTuple: generatePhonesTuple, partners: partners }
    }
);
print('Done Mapping Phones');
 
//endregion
 
//region Map-Reduce Events
 
var generateEventsTuple = function() {
    return {
        'Costs_Texts_Count': 0,
        'Costs_Texts_Value': 0,
        'Costs_ClientCalls_Count': 0,
        'Costs_ClientCalls_Value': 0
    };
};
 
var mapEvents = function() {
 
    var	me = this,
        dayTs = Math.floor(me.createdAt / (24 * 60 * 60 * 1000)) * (24 * 60 * 60 * 1000),
        tuple = generateEventsTuple(),
        pId = partners[me.acc.valueOf()];
 
    switch(me.type) {
        case 'Text':
            tuple['Costs_Texts_Count'] = 1;
            tuple['Costs_Texts_Value'] = me.xRef.value;
            break;
 
        case 'ClientCall':
            tuple['Costs_ClientCalls_Count'] = 1;
            tuple['Costs_ClientCalls_Value'] = me.xRef.value;
            break;
 
        default:
            break;
    }
 
    emit({DayTimestamp: dayTs, partner: pId}, tuple);
};
 
var reduceEvents = function(key, values) {
 
    var tuple = generateEventsTuple();
 
    for(var i = 0; i < values.length; i++) {
        for(var p in tuple) {
            tuple[p] += values[i][p];
        }
    }
 
    return tuple;
};
 
print('Mapping Events');
db.events.mapReduce(
    mapEvents,
    reduceEvents,
    {
        out: { replace: 'pre.by_reports.events' },
        query: {type: {$in: ['Text', 'ClientCall']}},
        scope : { generateEventsTuple: generateEventsTuple, partners: partners }
    }
);
print('Done Mapping Events');
 
//endregion
 
 
//Run this after Map-Reduces have been ran
//region Update Report Tables
 
print('Updating Signup Reports');
db.pre.by_reports.accounts.find().forEach(function(r){
 
    var key = r._id;
 
    db.reports.by_day.update(
        {partner:  key.partner, timestamp: key.DayTimestamp},
        {$set: r.value},
        true,
        false
    );
});
print('Done Signup Reports');
 
print('Updating Phone Reports');
db.pre.by_reports.phones.find().forEach(function(r){
 
    var key = r._id;
 
    db.reports.by_day.update(
        {partner:  key.partner, timestamp: key.DayTimestamp},
        {$set: r.value},
        true,
        false
    );
});
print('Done Phone Reports');
 
print('Updating Event Reports');
db.pre.by_reports.events.find().forEach(function(r){
 
    var key = r._id;
 
    db.reports.by_day.update(
        {partner:  key.partner, timestamp: key.DayTimestamp},
        {$set: r.value},
        true,
        false
    );
});
print('Done Event Reports');
//endregion

Comment by Ramon Fernandez Marina [ 03/Aug/15 ]

klesh, we haven't heard back from you for some time now. If this is still an issue for you, can you please provide the information requester above by Sam so we can investigate further?

Thanks,
Ramón.

Comment by Sam Kleinman (Inactive) [ 17/Jul/15 ]

Thanks for this report, and sorry that you've hit this issue!

I see a reference to MongoDB 2.4.9 in the output. Is this only the client used for this example, or is this also the version of the server? If you are using MongoDB 2.4, I'd be interested in seeing if you also see the same issue on the 3.0 or 2.6 branches of MongoDB.

Could you provide an example of the mapReduce operation that you used to produce this operation as well as an example document?

Regards,
sam

Generated at Thu Feb 08 03:51:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.