[SERVER-1689] Only allow equality matches on shard key in updates with upsert=true Created: 26/Aug/10 Updated: 12/Jul/16 Resolved: 03/Sep/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | None |
| Fix Version/s: | 1.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Mathias Stearn | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
db.foo.update({key: {$gt: 1}}, {...}) shouldn't be allowed |
| Comments |
| Comment by auto [ 03/Sep/10 ] |
|
Author: {'login': 'RedBeard0531', 'name': 'Mathias Stearn', 'email': 'mathias@10gen.com'}Message: Shard key in upsert query must be exact match |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/10 ] |
|
We can issue a performance warning though, but thats it |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/10 ] |
|
No - we should never ban anything unless we absolutely can't support it. |
| Comment by Mathias Stearn [ 26/Aug/10 ] |
|
That would require doing a getLastError on every call. How about doing that for 1.6.1 and banning it in 1.7.0? |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/10 ] |
|
for a non-equalit, non-multi update case, i guess we should hit in serial till it matches. we don't want to disallow that |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/10 ] |
|
So can require an equality if upsert is true. If its not true, then shouldn't add any restrictions. Have to be very careful about adding rules since people are in production |
| Comment by Mathias Stearn [ 26/Aug/10 ] |
|
Can't fire everywhere on non-multi since that would allow more than one document to be updated |
| Comment by Mathias Stearn [ 26/Aug/10 ] |
|
See the comments in the linked case for one example. It is currently possible to upsert a document without a shard key. I'll look over the update code tomorrow and see if there are any places it should be allowed. The only one I can think of off the top of my head would be multi-updates. |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/10 ] |
|
We should just fire update everywhere I think if we don't want to figure out where |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/10 ] |
|
Why? |