Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-44333

mongos accepts empty wc on commands that don't support writeConcern

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Backport Requested:
      v4.4

      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)
                      }
              }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              amirsaman.memaripour Amirsaman Memaripour
              Reporter:
              kevin.pulo Kevin Pulo
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: