[SERVER-44238] mapReduce fails to merge with sharded output in different database Created: 24/Oct/19  Updated: 24/Oct/19  Resolved: 24/Oct/19

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

Type: Bug Priority: Major - P3
Reporter: Charlie Swanson Assignee: Charlie Swanson
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-42511 Remove query knob internalQueryUseAgg... Closed
Operating System: ALL
Steps To Reproduce:

(function() {
"use strict";
const st = new ShardingTest({shards: 2});
const db = st.s.getDB("test");
assert.commandWorked(db.adminCommand({enableSharding: "test"}));
assert.commandWorked(db.adminCommand({enableSharding: "foreign"}));
const inputColl = db.input;
const outputCollOtherDB = db.getSiblingDB("foreign").output;
assert.commandWorked(
    db.adminCommand({shardCollection: inputColl.getFullName(), key: {_id: "hashed"}}));
assert.commandWorked(
    db.adminCommand({shardCollection: outputCollOtherDB.getFullName(), key: {_id: "hashed"}}));
 
assert.commandWorked(inputColl.insert([{_id: 1}, {_id: 2}, {_id: 3}]));
assert.commandWorked(outputCollOtherDB.insert({_id: 1, value: 0}));
function mapFn() {
    emit(this._id, 1);
}
function reduceFn(key, values) {
    return Array.sum(values);
}
 
assert.commandWorked(inputColl.mapReduce(mapFn, reduceFn, {
    out:
        {merge: outputCollOtherDB.getName(), db: outputCollOtherDB.getDB().getName(), sharded: true}
}));
 
st.stop();
}());

Participants:

 Description   

The attached reproduction script fails with:

[js_test:repro] 2019-10-24T18:52:40.920-0400 2019-10-24T18:52:40.920-0400 E  QUERY    [js] uncaught exception: Error: map reduce failed:{
[js_test:repro] 2019-10-24T18:52:40.921-0400 	"ok" : 0,
[js_test:repro] 2019-10-24T18:52:40.921-0400 	"errmsg" : "MR post processing failed: { operationTime: Timestamp(1571957560, 122), ok: 0.0, errmsg: \"The upsert document could not be inserted onto the shard targeted by the query, since its shard key belongs on a different shard. Cross-shard upserts ...\", code: 20, codeName: \"IllegalOperation\", $gleStats: { lastOpTime: { ts: Timestamp(1571957560, 122), t: 1 }, electionId: ObjectId('7fffffff0000000000000001') }, lastCommittedOpTime: Timestamp(1571957560, 113), $configServerState: { opTime: { ts: Timestamp(1571957560, 114), t: 1 } }, $clusterTime: { clusterTime: Timestamp(1571957560, 123), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } } }",
[js_test:repro] 2019-10-24T18:52:40.921-0400 	"operationTime" : Timestamp(1571957560, 124),
[js_test:repro] 2019-10-24T18:52:40.921-0400 	"$clusterTime" : {
[js_test:repro] 2019-10-24T18:52:40.921-0400 		"clusterTime" : Timestamp(1571957560, 124),
[js_test:repro] 2019-10-24T18:52:40.921-0400 		"signature" : {
[js_test:repro] 2019-10-24T18:52:40.921-0400 			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
[js_test:repro] 2019-10-24T18:52:40.921-0400 			"keyId" : NumberLong(0)
[js_test:repro] 2019-10-24T18:52:40.921-0400 		}
[js_test:repro] 2019-10-24T18:52:40.921-0400 	}
[js_test:repro] 2019-10-24T18:52:40.921-0400 } :
[js_test:repro] 2019-10-24T18:52:40.921-0400 _getErrorWithCode@src/mongo/shell/utils.js:25:13
[js_test:repro] 2019-10-24T18:52:40.921-0400 DBCollection.prototype.mapReduce@src/mongo/shell/collection.js:1085:15
[js_test:repro] 2019-10-24T18:52:40.921-0400 @repro.js:23:22
[js_test:repro] 2019-10-24T18:52:40.921-0400 @repro.js:1:2



 Comments   
Comment by Charlie Swanson [ 24/Oct/19 ]

Declining to fix this, should be fixed by the new implementation. Just filing for posterity.

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