If you include the shard-key in the query, but it is removed in the update operations, then the resulting inserted document will not contain the shard key, and will be lost to the sharded system queries.
Mongos should probably build the possibly inserted document to verify the shard-key exists in it before sending the update to the shard.
Take these examples
> db.s.update({shardkey:1}, {$unset: {shardkey:1}, $set: {otherfield : 5}}, true) // other example > db.s2.update({"embedded.key":1}, {$set : {embedded:{not_key:1}}}, true)
- related to
-
SERVER-7379 Immutable shardkey becomes mutable
- Closed
-
SERVER-6835 Sharding edge case upserts documents with multiple _id attributes
- Closed