[SERVER-13905] MapReduce to empty capped collection results in NON-capped collection Created: 12/May/14  Updated: 08/Mar/16  Resolved: 08/Mar/16

Status: Closed
Project: Core Server
Component/s: MapReduce
Affects Version/s: 2.4.10, 2.6.0
Fix Version/s: 3.1.3

Type: Bug Priority: Major - P3
Reporter: Avi Levy Assignee: Daniel Pasette (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

db.input.drop()
db.cap.drop()
db.input.insert(

{foo:"bar"}

)
var map = function() {
var key = this._id;
var value = 1;
emit(key, value );
}
var reduce = function(key, values) {
return Array.sum(values);
}

db.createCollection("cap",

{capped:true,size:100000}

)
db.cap.stats() // Collection is capped
db.input.mapReduce(map,reduce,{out:{reduce:"cap"}})
db.cap.stats() // Collection is not capped

//M/R to non empty capped collection
db.cap.drop()
db.createCollection("cap",

{capped:true,size:100000}

)
db.cap.insert(

{dummy:true}

)
db.cap.stats() // Collection is capped
db.input.mapReduce(map,reduce,{out:{reduce:"cap"}})
db.cap.stats() // Collection is capped

Participants:

 Description   

When doing a map reduce where the out collection is an empty capped collection and the out method of reduce, the result is a non-capped collection.
If the out is a non empty capped collection, then it remain capped.



 Comments   
Comment by Mathias Stearn [ 08/Mar/16 ]

This was fixed as part of SERVER-18227 in commit https://github.com/mongodb/mongo/commit/22de12dd4ac510cd2a37b643eb528673f651e21b. We now propagate all options when doing a map reduce onto an existing collection.

Comment by J Rassi [ 12/May/14 ]

Confirmed with 2.4.10, 2.6.1.

Assigning to dan@10gen.com for triage.

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