|
When mongod returns a WriteConcernError, there may be additional info in an errInfo field:
> db.test.insert({}, {writeConcern: {w: "majority", wtimeout: 1}})
|
WriteResult({
|
"nInserted" : 1,
|
"writeConcernError" : {
|
"code" : 64,
|
"codeName" : "WriteConcernFailed",
|
"errmsg" : "waiting for replication timed out",
|
>>> "errInfo" : {
|
>>> "wtimeout" : true
|
>>> }
|
}
|
})
|
However, when mongos gathers and merges WriteResults from shards, this info gets serialised to JSON and concatenated into the errmsg:
> db.test.insert({}, {writeConcern: {w: "majority", wtimeout: 1}})
|
WriteResult({
|
"nInserted" : 1,
|
"writeConcernError" : {
|
"code" : 64,
|
"codeName" : "WriteConcernFailed",
|
"errmsg" : "waiting for replication timed out; Error details: { wtimeout: true } at shard01"
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
}
|
})
|
Better would be if the errInfo from the shards was available in the top-level errInfo, eg:
> db.test.insert({}, {writeConcern: {w: "majority", wtimeout: 1}})
|
WriteResult({
|
"nInserted" : 1,
|
"writeConcernError" : {
|
"code" : 64,
|
"codeName" : "WriteConcernFailed",
|
"errmsg" : "waiting for replication timed out; Error details: { wtimeout: true } at shard01",
|
>>> "errInfo" : {
|
>>> "wtimeout" : true,
|
>>> "shards" : {
|
>>> "shard01" : {
|
>>> "wtimeout" : true,
|
>>> }
|
>>> }
|
}
|
}
|
})
|
(The existing errmsg format should be preserved for backwards compatibility.)
|