[SERVER-67072] Incorrect optimization of $match with $exists over the metaField in timeseries discards valid results Created: 07/Jun/22 Updated: 29/Oct/23 Resolved: 13/Jun/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 5.3.1, 6.0.0-rc8 |
| Fix Version/s: | 6.0.0-rc10, 6.1.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Milena Ivanova | Assignee: | David Percy |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
|||||||||||
| Backwards Compatibility: | Fully Compatible | |||||||||||
| Operating System: | ALL | |||||||||||
| Backport Requested: |
v6.0
|
|||||||||||
| Steps To Reproduce: |
|
|||||||||||
| Sprint: | QO 2022-06-13, QO 2022-06-27 | |||||||||||
| Participants: | ||||||||||||
| Linked BF Score: | 160 | |||||||||||
| Description |
|
When the following $match expression is pushed down before $_internalUnpackBucket, the meta field of the timeseries is not recognized correctly.
The $exists predicate is expanded into
which results in discarding valid documents from the result set. The correct expansion of the predicate over the metaField "tag" is:
The problem doesn't appear for other predicate, such as $eq, or if the predicate is the only one in $match, i.e the following aggregations produce correct results:
|
| Comments |
| Comment by Githook User [ 14/Jun/22 ] |
|
Author: {'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}Message: (cherry picked from commit b8f0fb561f5f6401dfc9a773777963f2f4bcb725) |
| Comment by Githook User [ 13/Jun/22 ] |
|
Author: {'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}Message: |
| Comment by Milena Ivanova [ 08/Jun/22 ] |
|
steve.la@mongodb.com, james.wahlin@mongodb.com The optimization of $exists that causes this issue was introduced by commit 610898a1ccec0afc3d38f7c29f2553d5b6102d30
As far as i can see the code is present in v5.3, but not in previous 5.x versions. I am working on a solution, but in case of a tight time pressure for release blocker it might be better if someone from the timeseries team takes over, since I am working on reduced hours. |