[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:
Related
is related to SERVER-1639 Failed to update an object with null ... Closed
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 SERVER-1689
http://github.com/mongodb/mongo/commit/6cc10ef09e3ceb5e21de53626ae8af0aa81a3d49

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.
We want seamless transition from non-sharding to sharded.

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?
We don't want to restrict usage if at all possible

Generated at Thu Feb 08 02:57:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.