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

Updates/deletes on sharded collections shouldn't affect orphan documents

    • Sharding EMEA
    • Fully Compatible
    • ALL
    • Sharding EMEA 2022-01-24, Sharding EMEA 2022-02-07

      Multi-updates and multi-deletes on sharded collections affect orphan documents, and are counted in WriteResult / getLastError stats. Writes to sharded collections should not affect orphan documents.

      Affects all currently-released versions.

      var st = new ShardingTest({shards:2});
      assert.commandWorked(st.getDB("admin").runCommand({enableSharding: "test"}));
      assert.commandWorked(st.getDB("admin").runCommand({shardCollection: "test.foo", key: {_id: "hashed"}}));
      assert.writeOK((new Mongo("localhost:30000")).getDB("test").foo.insert({_id:0}));
      assert.writeOK((new Mongo("localhost:30001")).getDB("test").foo.insert({_id:0}));
      var res = st.getDB("test").foo.update({}, {$set: {a: 1}}, {multi: true});
      assert.writeOK(res);
      assert.eq(1, res.nMatched); // fails with [1] != [2]
      res = st.getDB("test").foo.remove({});
      assert.eq(1, res.nRemoved); // fails with [1] != [2]
      

            Assignee:
            backlog-server-sharding-emea [DO NOT USE] Backlog - Sharding EMEA
            Reporter:
            jason.rassi Jason Rassi
            Votes:
            2 Vote for this issue
            Watchers:
            30 Start watching this issue

              Created:
              Updated:
              Resolved: