Report correct "n" when retryable update/delete by _id (no shard key) affects multiple docs

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide
      // Ensure the client is using a session with retryable writes enabled
      
      use test
      
      db.coll.createIndex({a: "hashed"});
      
      db.adminCommand(
        {shardCollection: "test.coll", key: {a: "hashed"}, numInitialChunks: 8})
      
      db.coll.insert({_id: 10, a: 1, b: 1}, {_id: 10, a: 11, b: 1});
      
      db.coll.updateOne({_id: 10}, {$set: {b: 0}})
      {
         acknowledged: true,
         insertedId: null,
         matchedCount: 1,
         modifiedCount: 1,
         upsertedCount: 0
      }
      
      db.coll.find()
      {_id: 10, a: 11, b: 0}
      {_id: 10, a: 1, b: 0} 
      Show
      // Ensure the client is using a session with retryable writes enabled use test db.coll.createIndex({a: "hashed" }); db.adminCommand( {shardCollection: "test.coll" , key: {a: "hashed" }, numInitialChunks: 8}) db.coll.insert({_id: 10, a: 1, b: 1}, {_id: 10, a: 11, b: 1}); db.coll.updateOne({_id: 10}, {$set: {b: 0}}) { acknowledged: true ,   insertedId: null ,   matchedCount: 1,   modifiedCount: 1,   upsertedCount: 0 } db.coll.find() {_id: 10, a: 11, b: 0} {_id: 10, a: 1, b: 0}
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      On v8.0, when a sharded collection that has an _id value that is present on multiple shards, a retryable multi:false update or delete that targets this _id value (without a shard key) will end up affecting more than one document (due to how retryable updates/deletes by _id without shard key are implemented in v8.0).

      Accepting that behavior for now, a user has reported that they noticed a case where an update by _id (without a shard key) was modifying two documents but was return "n=1". See the "Steps to Reproduce" section for an example.

      The goal of this ticket is to ensure that this bug is fixed in v9.0, and also to explore whether a fix should be backported to v8.0 and v8.2 as well.

            Assignee:
            Unassigned
            Reporter:
            Drew Paroski
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: