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

Include codeName field in writeErrors array

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • Query 2019-06-17, Query 2019-07-01

      Somewhere between v4.1.7-51-gb4f82034e6 and v4.1.8-73-ge2251dbc97, tests for the convenient transactions API started failing because the server ceased to return a code and code name for DuplicateKey errors.

      The test: https://github.com/mongodb/mongo-ruby-driver/blob/master/spec/spec_tests/data/transactions_api/callback-retry.yml#L129

      The response we are currently getting with 4.1.8:

      {"n"=>0, "writeErrors"=>[{"index"=>0, "code"=>11000, "keyPattern"=>{"_id"=>1}, "keyValue"=>{""=>1}, "errmsg"=>"E11000 duplicate key error collection: ruby-driver.test index: _id_ dup key: { _id: 1 }"}], "opTime"=>{"ts"=>#<BSON::Timestamp:0x000055dd583c1488 @seconds=1550719073, @increment=3>, "t"=>2}, "electionId"=>BSON::ObjectId('7fffffff0000000000000002'), "ok"=>1.0, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x000055dd583c0e70 @seconds=1550719073, @increment=3>, "signature"=>{"hash"=><BSON::Binary:0x47204578231900 type=generic data=0x0000000000000000...>, "keyId"=>0}}, "operationTime"=>#<BSON::Timestamp:0x000055dd583c0bc8 @seconds=1550719073, @increment=3>}
      

      It includes errmsg but no code or code name.

      4.0 response for comparison:

      {"operationTime"=>#<BSON::Timestamp:0x00005620520854f8 @seconds=1550719590, @increment=3>, "ok"=>0.0, "errmsg"=>"E11000 duplicate key error collection: ruby-driver.test index: _id_ dup key: { : 1 }", "code"=>11000, "codeName"=>"DuplicateKey", "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x000056205209c680 @seconds=1550719590, @increment=3>, "signature"=>{"hash"=><BSON::Binary:0x47348407684780 type=generic data=0x0000000000000000...>, "keyId"=>0}}}
      

      It looks like previously DuplicateKey was returned as a top level error, and then it had code name and code, and now DuplicateKey is a write error and it does not have code name and code anymore.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: