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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.4.1, 4.7.0
    • Component/s: Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.4, v4.2
    • Sprint:
      Sharding 2020-07-13, Sharding 2020-06-15, Sharding 2020-06-29

      Description

      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());
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: