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

mongos should forward WriteConcernError errInfo from shards

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying, Sharding
    • None
    • Query Optimization
    • Minor Change

      When mongod returns a WriteConcernError, there may be additional info in an errInfo field:

      > db.test.insert({}, {writeConcern: {w: "majority", wtimeout: 1}})
      WriteResult({
              "nInserted" : 1,
              "writeConcernError" : {
                      "code" : 64,
                      "codeName" : "WriteConcernFailed",
                      "errmsg" : "waiting for replication timed out",
      >>>             "errInfo" : {
      >>>                     "wtimeout" : true
      >>>             }
              }
      })
      

      However, when mongos gathers and merges WriteResults from shards, this info gets serialised to JSON and concatenated into the errmsg:

      > db.test.insert({}, {writeConcern: {w: "majority", wtimeout: 1}})
      WriteResult({
              "nInserted" : 1,
              "writeConcernError" : {
                      "code" : 64,
                      "codeName" : "WriteConcernFailed",
                      "errmsg" : "waiting for replication timed out; Error details: { wtimeout: true } at shard01"
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              }
      })
      

      Better would be if the errInfo from the shards was available in the top-level errInfo, eg:

      > db.test.insert({}, {writeConcern: {w: "majority", wtimeout: 1}})
      WriteResult({
              "nInserted" : 1,
              "writeConcernError" : {
                      "code" : 64,
                      "codeName" : "WriteConcernFailed",
                      "errmsg" : "waiting for replication timed out; Error details: { wtimeout: true } at shard01",
      >>>             "errInfo" : {
      >>>                     "wtimeout" : true,
      >>>                     "shards" : {
      >>>                         "shard01" : {
      >>>                             "wtimeout" : true,
      >>>                         }
      >>>                     }
                      }
              }
      })
      

      (The existing errmsg format should be preserved for backwards compatibility.)

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: