[SERVER-78862] Fix serialization of nested $elemMatch's Created: 11/Jul/23  Updated: 29/Oct/23  Resolved: 28/Jul/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 7.0.1

Type: Bug Priority: Major - P3
Reporter: Will Buerger Assignee: Will Buerger
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-85070 PM-2885 Tracking: Known find correctn... Closed
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0
Participants:

 Description   

After serialization with "LiteralSerializationPolicy::kToRepresentativeParseableValue", $elemMatch fails to re-parse with the error (with $gte or equivalent operators)

unknown top level operator: $gte 

It seems like this may be the case because multiple $elemMatch predicates for one field are dispatched with the syntax 

{ a : { $elemMatch :{$elemMatch:{ b: { $gte: 1, $lte: 1 } } } } }

but are serialized to 

{ a: { $elemMatch: { $elemMatch: { $and: [ { $lt: 1 }, { $gt: 1 } ] } } } } 

 It seems the $and syntax may be causing re-parseability issues.

 

You can see the relevant failing tests in the query_stats_passthrough in BF-29272 and BF-29276



 Comments   
Comment by Githook User [ 18/Aug/23 ]

Author:

{'name': 'Will Buerger', 'email': 'will.buerger@mongodb.com', 'username': 'wbuerger46'}

Message: SERVER-78862: Fix nested $elemMatch serialization
Branch: v7.0
https://github.com/mongodb/mongo/commit/66deadc81494901065ad455a49bcbbdbf9a8651b

Comment by Githook User [ 27/Jul/23 ]

Author:

{'name': 'Naafiyan Ahmed', 'email': 'naafiyan.ahmed@mongodb.com', 'username': 'naafiyan'}

Message: SERVER-78862 fixed nested $elemMatch serialization
Branch: master
https://github.com/mongodb/mongo/commit/f1c003c839e3b900b7529d178570cecb3a647b6a

Generated at Thu Feb 08 06:39:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.