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

Write concern error on dropDatabase command also reports command failure

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Catalog, Replication
    • ALL
    • v4.0
    • Hide

      Start a 3-node replica set and connect to the primary in the shell (tested with 4.1.0-77-gf0e5229). Then create a database and drop it with w:5:

      MongoDB Enterprise repl0:PRIMARY> db.test.insert({})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise repl0:PRIMARY> db.runCommand({dropDatabase: 1, writeConcern : {w : 5} })
      {
      	"writeConcernError" : {
      		"code" : 100,
      		"codeName" : "CannotSatisfyWriteConcern",
      		"errmsg" : "Not enough data-bearing nodes"
      	},
      	"operationTime" : Timestamp(1527552755, 1),
      	"ok" : 0,
      	"errmsg" : "dropDatabase test failed waiting for 1 collection drops (most recent drop optime: { ts: Timestamp(1527552755, 1), t: 2 }) to replicate. :: caused by :: Not enough data-bearing nodes",
      	"code" : 100,
      	"codeName" : "CannotSatisfyWriteConcern",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1527552755, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      Expected results (tested with 4.0.0-rc0):

      MongoDB Enterprise repl0:PRIMARY> db.test.insert({})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise repl0:PRIMARY> db.runCommand({dropDatabase: 1, writeConcern : {w : 5} })
      {
      	"dropped" : "test",
      	"ok" : 1,
      	"writeConcernError" : {
      		"code" : 100,
      		"codeName" : "CannotSatisfyWriteConcern",
      		"errmsg" : "Not enough data-bearing nodes"
      	},
      	"operationTime" : Timestamp(1527553089, 2),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1527553089, 2),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      
      Show
      Start a 3-node replica set and connect to the primary in the shell (tested with 4.1.0-77-gf0e5229). Then create a database and drop it with w:5 : MongoDB Enterprise repl0:PRIMARY> db.test.insert({}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise repl0:PRIMARY> db.runCommand({dropDatabase: 1, writeConcern : {w : 5} }) { "writeConcernError" : { "code" : 100, "codeName" : "CannotSatisfyWriteConcern" , "errmsg" : "Not enough data-bearing nodes" }, "operationTime" : Timestamp(1527552755, 1), "ok" : 0, "errmsg" : "dropDatabase test failed waiting for 1 collection drops (most recent drop optime: { ts: Timestamp(1527552755, 1), t: 2 }) to replicate. :: caused by :: Not enough data-bearing nodes" , "code" : 100, "codeName" : "CannotSatisfyWriteConcern" , "$clusterTime" : { "clusterTime" : Timestamp(1527552755, 1), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } } Expected results (tested with 4.0.0-rc0): MongoDB Enterprise repl0:PRIMARY> db.test.insert({}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise repl0:PRIMARY> db.runCommand({dropDatabase: 1, writeConcern : {w : 5} }) { "dropped" : "test" , "ok" : 1, "writeConcernError" : { "code" : 100, "codeName" : "CannotSatisfyWriteConcern" , "errmsg" : "Not enough data-bearing nodes" }, "operationTime" : Timestamp(1527553089, 2), "$clusterTime" : { "clusterTime" : Timestamp(1527553089, 2), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } }
    • Storage NYC 2018-06-18

      A write concern error normally results in a successful command (ok: 1) and a writeConcernError document. But in recent 4.1 builds it results in a command failure (ok: 0) as well for the dropDatabase command, making it inconsistent with other commands.

      The result is that a driver may throw the wrong exception type. For example, the Java driver will throw a MongoCommandException instead of a MongoWriteConcernException. This causes several write concern-related regression tests to fail.

            Assignee:
            louis.williams@mongodb.com Louis Williams
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: