[SERVER-20641] Equality query on _id with a sort fails with an InternalError when routed through mongos Created: 25/Sep/15 Updated: 07/Oct/15 Resolved: 01/Oct/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying, Sharding |
| Affects Version/s: | None |
| Fix Version/s: | 3.1.9 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | David Storch | Assignee: | YunHe Wang |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Sprint: | QuInt A (10/12/15) |
| Participants: |
| Description |
|
This is a bug in the new mongos read path, so it only affects the master branch. It does not affect any stable versions. The following script reproduces the problem:
Looks like a bad interaction between idhack and sortKey meta-projection. |
| Comments |
| Comment by Githook User [ 01/Oct/15 ] |
|
Author: {u'username': u'yhjw88', u'name': u'Yunhe (John) Wang', u'email': u'yunhe.wang@mongodb.com'}Message: |
| Comment by YunHe Wang [ 28/Sep/15 ] |
|
It appears that the query plan for the find() on "_id" consists of just IDHACK on mongod, which makes sense since the sort basically does nothing if we're doing equality on "_id". mongos still sends the $meta sortkey projection to the shards though, and since no SORTKEY_GENERATOR stage is added, the final PROJECT stage on the shards will fail. The simplest solution may be to add the SORTKEY_GENERATOR stage to be processed after the IDHACK stage if there is a $meta sortkey projection, but there could be a better solution. |
| Comment by David Storch [ 25/Sep/15 ] |
|
Thanks to rstam for discovering this! |