[SERVER-27207] Find on view with sort through mongos may incorrectly return empty result set Created: 29/Nov/16 Updated: 05/Apr/17 Resolved: 01/Dec/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | 3.4.1, 3.5.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Kyle Suarez | Assignee: | Kyle Suarez |
| Resolution: | Done | Votes: | 0 |
| Labels: | 34errata, read-only-views | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Backport Completed: | |||||||||
| Sprint: | Query 2016-12-12 | ||||||||
| Participants: | |||||||||
| Description |
|
A find() with a sort() on a mongos may return an empty result set:
There's a simple workaround, which is to use the aggregation pipeline:
|
| Comments |
| Comment by Githook User [ 01/Dec/16 ] |
|
Author: {u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}Message: (cherry picked from commit 1db6b26bcfdc67992c52739f50deacd31edc4fc0) |
| Comment by Githook User [ 01/Dec/16 ] |
|
Author: {u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}Message: |
| Comment by Kyle Suarez [ 30/Nov/16 ] |
|
In AsyncResultsMerger::handleBatchResponse(), we detect the view kickback error code from the primary shard and fill out a ClusterQueryResult with the new resolved view. However, we only fill out the docBuffer of the remote. We don't touch the merge queue in any way, so it's left empty. If the query has a sort, we call AsyncResultsMerger::nextReadySorted(), which consults the top of the merge queue. Since it's empty, it returns an empty result. There are a few ways we could fix this. Off the top of my head, we could also push remoteIndex to _mergeQueue when populating the result's view definition; or we could change the code to not go down the sorted codepath if a view's been discovered. I leave the strategy up to david.storch. |