[SERVER-14491] error message for upserts without shard key misleading Created: 07/Jul/14 Updated: 22/May/19 Resolved: 22/May/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding, Write Ops |
| Affects Version/s: | 2.6.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Alexander Komyagin | Assignee: | Janna Golden |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Sprint: | Sharding 2019-04-22, Sharding 2019-05-06, Sharding 2019-05-20, Sharding 2019-06-03 |
| Participants: |
| Description |
|
Upserts require enforcing a uniqueness constraint via a query - in a sharded cluster the only way to do this is if the upsert query is targeted by the shard key. The error message "does not contain shard key", however, is a bit vague in that the shard key may be included in the update expression of the update, but the query also requires it. Original description:
2.4 behavior:
|
| Comments |
| Comment by Janna Golden [ 22/May/19 ] | |||||||||||||||||||||||
|
This has been fixed as a part of | |||||||||||||||||||||||
| Comment by Akira Kurogane [ 01/Mar/17 ] | |||||||||||||||||||||||
|
For ticket search reasons: please note that the error string "does not contain shard key for pattern" in 3.2 (or lower?) is replaced by "An upsert on a sharded collection must contain the shard key and have the simple collation" in 3.4, and the context in this ticket applies to it so long as it is just a shard key issue and collation is absent/irrelevant. | |||||||||||||||||||||||
| Comment by Alexandr Bolbat [ 29/Jun/16 ] | |||||||||||||||||||||||
|
Hello We have exactly the same issue. On our mongo setup (geographically distributed sharded cluster with shard tags) with next configuration:
Can't execute the next "upsert query":
Error message is:
Current workaround is to execute find query with:
and:
But i think this work can be done by 'mongos' with '$setOnInsert' operator without our participation. |