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

ShardCollection allows nested patterns but updateOne does not

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Cluster Scalability
    • Sharding NYC 2023-01-23
    • 3

      Problem

      In the following scenario, it seems impossible to update the shard key:

       

      use test
      sh.enableSharding("test")
      sh.shardCollection( "test.coll",  { a: 1, "a.b": 1 })
      db.coll.insert({a: { b: 1}})
      
      db.coll.updateOne({a: { b: 1}}, {$set: {"a": { "b": 2}}}, { upsert: false })
      // "Shard key update is not allowed without specifying the full shard key in the query"
      
      db.coll.updateOne({a: { b: 1}, "a.b": 1}, {$set: {"a": { "b": 2}}}, { upsert: false })
      // same error
      
      db.coll.updateOne({"a.b": 1}, {$set: {"a": { "b": 2}}}, { upsert: false })
      // same error

      Solution

      It is not clear to me if shardCollection should reject such pattern or if the logic used by updateOne to validate the filter has an issue when one field contains the other.

      Impact

      This was found while designing REP-160 (unlike topologies support for cluster to cluster replication).

      Acceptance Criteria

      Either shardCollection should reject nested patterns or updateOne should support them. There might be other APIs to fix too (e.g. find).

            Assignee:
            backlog-server-cluster-scalability [DO NOT USE] Backlog - Cluster Scalability
            Reporter:
            frederic.vitzikam@mongodb.com Frederic Vitzikam
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: