This seems to happen on both mongos and mongod.
Here is an insert (non-FLE) that encounters a WriteConcernError (WCE). Note that n: 1 because the write went through, and the WCE is reported in the writeConcernError field.
{ "n" : 1, "writeConcernError" : { "code" : 100, "codeName" : "UnsatisfiableWriteConcern", "errmsg" : "UnsatisfiableWriteConcern: Not enough data-bearing nodes; Error details: { writeConcern: { w: 3, wtimeout: 0, provenance: \"clientSupplied\" } } at shard-rs0", "errInfo" : { } }, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1695160343, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1695160343, 1) }
When using FLE, the WCE is placed into the writeErrors field. I'm not sure how drivers would then interpret the error. Note that the write doesn't go through either (n: 0)
{ "n" : 0, "opTime" : Timestamp(1695160105, 3), "writeErrors" : [ { "index" : 0, "code" : 64, "errmsg" : "Write concern error committing internal transaction :: caused by :: waiting for replication timed out; Error details: { wtimeout: true, writeConcern: { w: 2, wtimeout: 2000, provenance: \"clientSupplied\" } }" } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1695160105, 7), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1695160105, 3) }
This led me to wonder what happens when an actual error, like DuplicateKeyError shows up along with a WCE. The result is that the WCE is hidden (this is basically the bug from SERVER-78311):
{ "n" : 0, "opTime" : Timestamp(1695221129, 11), "writeErrors" : [ { "index" : 0, "code" : 11000, "errmsg" : "E11000 duplicate key error collection: bulk_fle.basic index: _id_ dup key: { _id: 1.0 } found value: RecordId(1)", "keyPattern" : { "_id" : 1 }, "keyValue" : { "_id" : 1 }, "foundValue" : NumberLong(1), "duplicateRid" : NumberLong(1) } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1695221129, 13), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1695221129, 11) }
I'm looking to implement FLE + bulkWrite + WCE handling on mongos and I was looking into the existing behavior and that's when I found this.
- is depended on by
-
SERVER-81280 Handle writeConcernErrors for FLE in bulkWrite
- Blocked
- is related to
-
SERVER-78311 mongos does not report writeConcernError in presence of writeErrors for insert command
- Closed
-
SERVER-86299 Test and fix FLE2 writeConcernError reporting in sharded writes
- In Code Review
- related to
-
SERVER-81259 updateOne without shard key does not handle WriteConcernErrors properly
- Needs Scheduling
- split to
-
SERVER-84081 FLE2 write error hides write concern error
- In Progress