MapReduce fails without error message

13 views
Skip to first unread message

Dror Cohen

unread,
Jun 30, 2015, 9:46:06 AM6/30/15
to mongod...@googlegroups.com
Hi everyone,

I'm performing an incremental map reduce on a 2.6 mongod instance and everything worked fine and dandy until recently.

db.runCommand({ 
mapreduce: "somePreAggregatedCollection",
query
: {
   
"start" : {
        $gt
: previousRun,
       
}
   
},
map
: function Map() {
   
delete this.start;
   
delete this.end;
   
delete this._id;
   
var key = this.user,
        value
= this;
   
delete value.user;
    emit
(key, value);
},
reduce
: function Reduce(user, aggregationData) {
   
var result = {};
    aggregationData
.forEach(function(timespan){
       
Object.keys(timespan).forEach(function(field){
           
if (!result[field] || (field.indexOf('Last', field.length - 5) != -1)) {
                result
[field] = timespan[field];
           
} else if ((field.indexOf('Count', field.length - 5) != -1) || (field.indexOf('Sum', field.length - 5) != -1)) {
                result
[field] += timespan[field];
           
} else if (field.indexOf('Min', field.length - 5) != -1) {
                result
[field] = (result[field] > timespan[field]) ? timespan[field] : result[field];
           
} else if (field.indexOf('Max', field.length - 5) != -1) {
                result
[field] = (result[field] < timespan[field]) ? timespan[field] : result[field];
           
}
       
});
   
});
   
return result;
},
sort
: { "user" : 1, "start" : 1 },
out : { reduce: "lifetime_agg"  },
jsMode
: true

I'm pretty sure that I'm not breaking any requirements and nothing is nowhere near the limits, but the things is that if I don't use the query to make chunks small enough the command does nothing at all, it simply responds with:
counts: {
    input
: 0,
    emit
: 0,
    reduce
: 0,
    output
: number of records already in lifetime_agg
}

I would have expected some sort of an error message, and the whole thing still works if I force it to run with a smaller query result.

P.S. jsMode is set to true because I was tweaking with it and the number of records is nowhere near 500,000. It behaves the same way with jsMode set to false.

Asya Kamsky

unread,
Jun 30, 2015, 12:46:23 PM6/30/15
to mongodb-user
Your mapReduce is doing a query to select a subset of records to run over:

query: {
"start" : {
$gt: previousRun,
}
}

Is it possible that either "previousRun" value is suddenly not being
populated properly or "start" field is not being set properly in new
records?

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/2edf2627-e48b-4482-aed5-996336b7c9de%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages