[SERVER-11632] Write command error field errmsg concatenation broken Created: 08/Nov/13  Updated: 19/May/14  Resolved: 08/Jan/14

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

Type: Bug Priority: Major - P3
Reporter: Christian Amor Kvalheim Assignee: Greg Studer
Resolution: Won't Fix Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Steps To Reproduce:

//
// Start a shard
var s = new ShardingTest("count1", 2, 1);
var db = s.getDB("test");
var collectionName = "batch_write_protocol";
var coll = db.getCollection(collectionName);
 
jsTest.log("Starting sharded write command tests...");
 
var request;
var result;
 
// Create unique index
coll.remove();
coll.dropIndexes();
coll.ensureIndex({a : 1}, {unique : true});
 
//
// Multiple docurments insert with errors, w:1 write concern specified, ordered:false
request = {insert : collectionName
	, documents: [{a:1}, {a:1}, {a:2}, {a:1}, {a:1}]
	, writeConcern:{w:1}
	, ordered:false};
result = coll.runCommand(request)
jsTest.log(JSON.stringify(result, null, 2))

Participants:

 Description   

All the errmsg's in the errDetails arrays are concatenated together into the top level errmsg. This will cause a quicker return message overflow size in the case where a write command overflows the 16MB return message.

{
  "ok": 0,
  "errCode": 65,
  "errmsg": "multiple errors in batch : E11000 duplicate key error index: test.batch_write_protocol.$a_1  dup key: { : 1.0 } :: and :: E11000 duplicate key error index: test.batch_write_protocol.$a_1  dup key: { : 1.0 } :: and :: E11000 duplicate key error index: test.batch_write_protocol.$a_1  dup key: { : 1.0 }",
  "n": 2,
  "errDetails": [
    {
      "index": 1,
      "errCode": 11000,
      "errmsg": "E11000 duplicate key error index: test.batch_write_protocol.$a_1  dup key: { : 1.0 }"
    },
    {
      "index": 3,
      "errCode": 11000,
      "errmsg": "E11000 duplicate key error index: test.batch_write_protocol.$a_1  dup key: { : 1.0 }"
    },
    {
      "index": 4,
      "errCode": 11000,
      "errmsg": "E11000 duplicate key error index: test.batch_write_protocol.$a_1  dup key: { : 1.0 }"
    }
  ]
}



 Comments   
Comment by Daniel Pasette (Inactive) [ 08/Jan/14 ]

we don't concat error messages anymore.

Comment by Greg Studer [ 05/Dec/13 ]

We should have lots of headroom in the return size with our hardcoded batch size limit - but yeah, improving error reporting here is on our radar.

If we're even a little smart about guessing a good message at the top level, it would help users a whole lot.

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