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

multi=true updates can modify the shard key of orphan documents and cause them to become owned

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.1, 4.7.0, 4.2.15
    • Affects Version/s: 4.2.0
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v4.4, v4.2
    • Sharding 2020-07-13, Sharding 2020-06-15, Sharding 2020-06-29

      The check for whether the shard key is being modified in a multi=true update happens after the check for whether the shard owns the document being updated has said it's fine to proceed with the update. We should instead disallow any attempts to change the shard key in multi=true updates.

      // If the shard key fields remain unchanged by this update or if this document is an orphan and
      // so does not belong to this shard, we can skip the rest of the checks.
      >if ((newShardKey.woCompare(oldShardKey) == 0) || !metadata->keyBelongsToMe(oldShardKey)) {
          return false;
      }
      
      ...
      
      // We do not allow updates to the shard key when 'multi' is true.
      uassert(ErrorCodes::InvalidOptions,
              "Multi-update operations are not allowed when updating the shard key field.",
              !_params.request->isMulti());
      

            Assignee:
            haley.connelly@mongodb.com Haley Connelly
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: