-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Cluster Scalability
-
Sharding NYC 2023-01-23
-
3
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
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).