[SERVER-44333] mongos accepts empty wc on commands that don't support writeConcern Created: 31/Oct/19  Updated: 29/Oct/23  Resolved: 11/Mar/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.4.0-rc0, 4.7.0

Type: Bug Priority: Major - P3
Reporter: Kevin Pulo Assignee: Amirsaman Memaripour
Resolution: Fixed Votes: 0
Labels: neweng, sharding-4.4-stabilization, sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Documented
is documented by DOCS-13508 Investigate changes in SERVER-44333: ... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v4.4
Participants:

 Description   

This is inconsistent with mongod, which always rejects the writeConcern field on commands where supportsWriteConcern() returns false.

The problem is that this check is using !wcResult.usedDefault, rather than something like request.body.hasField(WriteConcernOptions::kWriteConcernField).

mongod:

> db.runCommand({ping:1, writeConcern:{w:1}})
{
        "ok" : 0,
        "errmsg" : "Command does not support writeConcern",
        "code" : 72,
        "codeName" : "InvalidOptions"
}
> db.runCommand({ping:1, writeConcern:{}})
{
        "ok" : 0,
        "errmsg" : "Command does not support writeConcern",
        "code" : 72,
        "codeName" : "InvalidOptions"
}

mongos:

mongos> db.runCommand({ping:1, writeConcern:{w:1}})
{
        "ok" : 0,
        "errmsg" : "Command does not support writeConcern",
        "code" : 72,
        "codeName" : "InvalidOptions",
        "operationTime" : Timestamp(1572499322, 1),
        "$clusterTime" : {
                "clusterTime" : Timestamp(1572499322, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
}
mongos> db.runCommand({ping:1, writeConcern:{}})
{
        "ok" : 1,
        "operationTime" : Timestamp(1572499322, 1),
        "$clusterTime" : {
                "clusterTime" : Timestamp(1572499322, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
}



 Comments   
Comment by Githook User [ 30/Mar/20 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-44333 Extend write concern validation for mongos

Mongos should not accept an empty (default) write concern for commands that do not support write concerns.

(cherry picked from commit e0077e34ae71580f99205db961980f0403665652)
Branch: v4.4
https://github.com/mongodb/mongo/commit/030a1b3c2eb5d4973c72ed661b4f97acd3e3d332

Comment by Githook User [ 11/Mar/20 ]

Author:

{'username': 'samanca', 'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com'}

Message: SERVER-44333 Extend write concern validation for mongos

Mongos should not accept an empty (default) write concern for commands that do not support write concerns.
Branch: master
https://github.com/mongodb/mongo/commit/e0077e34ae71580f99205db961980f0403665652

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