[SERVER-39019] $elemMatch $ne serialization is incorrect, doesn't roundtrip Created: 15/Jan/19 Updated: 29/Oct/23 Resolved: 19/Feb/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | 3.6.15, 4.0.7, 4.1.9, 3.4.24 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Brigitte Lamarche (Inactive) | Assignee: | James Wahlin |
| 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: |
v4.0, v3.6, v3.4, v3.2
|
||||||||||||||||||||||||
| Sprint: | Query 2019-01-28, Query 2019-02-11, Query 2019-02-25 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Description |
|
To reproduce: ./mongo > pipeline = [\{ $match: { 'a': { $elemMatch: {$ne:400 }} }} ] > db.hello.explain().aggregate(pipeline) Result looks like:
Note that parsedQuery does not make sense. Namely, it has a key value which is an empty string. |
| Comments |
| Comment by Githook User [ 24/Sep/19 ] |
|
Author: {'name': 'James Wahlin', 'username': 'jameswahlin', 'email': 'james.wahlin@mongodb.com'}Message: (cherry picked from commit 3db787da9dc453192adcf7706991d2d09f0ff0c7) |
| Comment by James Wahlin [ 16/Sep/19 ] |
|
Thanks for reporting this zhihuifan@163.com. I have opened |
| Comment by zhihui fan [ 16/Sep/19 ] |
|
looks I found another corner case for this issue, just FYI. try: { { "a" : { "$elemMatch" : { "$not" : { "$ne" : 400 }} } }
|
| Comment by Githook User [ 11/Sep/19 ] |
|
Author: {'name': 'James Wahlin', 'username': 'jameswahlin', 'email': 'james.wahlin@mongodb.com'}Message: |
| Comment by David Storch [ 05/Sep/19 ] |
|
bduncan@visualmining.com, we are continuing to work on the custom fix for this issue on the 3.6 branch, but at the moment it has not been merged yet. The "fixVersion" field will be updated accordingly when the fix is merged. You should also see a comment on this ticket linking to the github commit when this is merged to the 3.6 branch. Our apologies for the delay! We found a correctness issue with the originally proposed backport and are working through it. |
| Comment by Bruce Duncan [ 05/Sep/19 ] |
|
@david.storch Was this fix merged and present in v3.6.14? If not, when will it get pushed out? |
| Comment by David Storch [ 03/Jul/19 ] |
|
brucehappy, apologies for the delay. We've been discussing the best route forward internally, since the fix implemented for 4.0 and 4.2 does not backport cleanly to 3.6 or older branches. Attempting to backport the complete fix to older stable branches seems too risky. After some discussion, we think we have identified an appropriate custom fix that would be safe for backport to the 3.6 branch. I've scheduled the custom fix to be worked on by the Server Query team in our upcoming development iteration ending on July 29th. Once the fix is merged, it will be released in the next 3.6.x version. |
| Comment by Bruce Duncan [ 01/Jul/19 ] |
|
Could I please get an ETA on backporting this to 3.6 @james.wahlin? Its been 4 months since it was requested. |
| Comment by Githook User [ 19/Feb/19 ] |
|
Author: {'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}Message: (cherry picked from commit 4677879eb75934ee3cd76c9e9807f6892ac17400)
(cherry picked from commit a2c0f15d6dc9fcda389b18b54287c4fcb5be44cd) |
| Comment by Githook User [ 19/Feb/19 ] |
|
Author: {'name': 'James Wahlin', 'username': 'jameswahlin', 'email': 'james@mongodb.com'}Message: |
| Comment by James Wahlin [ 17/Jan/19 ] |
|
When a MatchExpression tree representing the query {x: {$ne: 1}} is serialized, we serialize to {$nor: [{$eq: 1}]} rather than {x: {$not: {$eq: 1}}} which are equivalent statements. We run in to trouble however when the $ne is embedded in a $elemMatch. In this case we attempt to serialize {x: {$elemMatch: {$ne: 1}}} to {x: {$elemMatch: {$nor: [{$eq: 1}]}}}, which is not valid as $nor expects children that are top-level expressions. |
| Comment by Brigitte Lamarche (Inactive) [ 15/Jan/19 ] |
|
|