|
Here's a concrete example on MongoDB 4.0.4:
MongoDB Enterprise 3de4d42f-b25b-49d6-8997-1dd19e067fb7:PRIMARY> db.adminCommand({createUser:"foo2", pwd:"pwd", roles:["read"], writeConcern:{w:"majority", wtimeout:1}})
|
{
|
"ok" : 0,
|
"errmsg" : "waiting for replication timed out",
|
"code" : 64,
|
"codeName" : "WriteConcernFailed",
|
"writeConcernError" : {
|
"code" : 64,
|
"codeName" : "WriteConcernFailed",
|
"errmsg" : "waiting for replication timed out",
|
"errInfo" : {
|
"wtimeout" : true
|
}
|
}
|
}
|
To be consistent with other commands that report writeConcernError the output should be:
{
|
"ok" : 1,
|
"writeConcernError" : {
|
"code" : 64,
|
"codeName" : "WriteConcernFailed",
|
"errmsg" : "waiting for replication timed out",
|
"errInfo" : {
|
"wtimeout" : true
|
}
|
}
|
}
|
|