[SERVER-14973] Support $eq with sharding Created: 20/Aug/14  Updated: 27/Oct/15  Resolved: 17/Oct/14

Status: Closed
Project: Core Server
Component/s: Querying, Sharding
Affects Version/s: None
Fix Version/s: 2.7.8

Type: Improvement Priority: Critical - P2
Reporter: Scott Hernandez (Inactive) Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-1367 create an $eq operator for queries th... Closed
related to DOCS-4526 $eq + sharding Closed
is related to SERVER-17399 db.collection.update() upsert behavio... Closed
Tested
tested by SERVER-16317 Additional tests for $eq operator Closed
Backwards Compatibility: Minor Change
Participants:

 Description   

Update query targeting, shard key validation to support the new query operator $eq.



 Comments   
Comment by Greg Studer [ 17/Oct/14 ]

This change clarifies some edge cases in our upsert syntax, for example:

Empty collection and running against a single mongod:

db.coll.update({ _id : 1 }, { a : 1 }, { upsert : true });
v2.6 and v2.8 => upserted with _id : 1
 
db.coll.update({ _id : { $eq : 1 } }, { a : 1 }, { upsert : true });
v2.6 => error
v2.8 => upserted with _id : 1
 
db.coll.update({ _id.x : 1, _id.y : 2 }, { $set : { a : 1 } }, { upsert : true });
v2.6, v2.8 => upserted with _id : { x : 1, y : 2 }
 
db.coll.update({ _id.x : 1, _id.y : 2 }, { a : 1 }, { upsert : true });
v2.6 => on upsert, confusingly, a random ObjectId is generated
v2.8 => error, must specify full _id value

Sharded with k : 1:

db.coll.update({ k : { $eq : 1 } }, { $set : { k : 1 } }, { upsert : true })
2.6 => error
2.8 => upserted with k : 1
 
db.coll.update({ k : { $eq : 1 }, k.x : 1 }, { $set : { k : 1 } }, { upsert : true })
v2.6 => error, update conflict at mongod
v2.8 => error extracting shard key k

Comment by Greg Studer [ 17/Oct/14 ]

Author:

{u'username': u'gregstuder', u'name': u'Greg Studer', u'email': u'greg@10gen.com'}

Message: SERVER-13635 take ownership of shard key in shardCollection
Branch: master
https://github.com/mongodb/mongo/commit/28adefebaddfaabe11db7bdf73a974477bc44484

EDIT: This commit was mistakenly attached to SERVER-13635, but properly belongs here as a bugfix for the previous commit.

Comment by Githook User [ 16/Oct/14 ]

Author:

{u'username': u'gregstuder', u'name': u'Greg Studer', u'email': u'greg@10gen.com'}

Message: SERVER-14973 consolidate shard key parsing, cleanup shard key patterns
Branch: master
https://github.com/mongodb/mongo/commit/22f8b6259602a76f8d22cba8b1098f9e3c90a36f

Comment by Valeri Karpov [ 20/Aug/14 ]

FWIW here's a js test case to make sure $eq works as expected, at least for my use case:

db.x.insert({ x: 5 });
db.x.find({ a: { $eq: { $gt: 4 } } }); // should return no results

Generated at Thu Feb 08 03:36:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.