[SERVER-82979] Resolve inconsistency in ABT and SBE assumptions for duplicate predicates in $or Created: 08/Nov/23  Updated: 04/Dec/23  Resolved: 29/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Lynne Wang Assignee: Lynne Wang
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-82642 Add isInListData instruction in SBE t... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.2, v7.1, v7.0
Steps To Reproduce:

Failing Test: jstests/query_golden/match_with_and_or.js

  • When we run a $or find query over two duplicate predicates with parameterization, no results are getting returned

Failing Query:

{{[{"$match":{"

$or":[

{"a":1}

,{"a":1}

] }}]}}

Sprint: QO 2023-11-13, QO 2023-11-27, QO 2023-12-11
Participants:

 Description   

If there are predicates over the same path in $or, they are translated into $in during match expression optimization. It also provides deduplication, so for the query above, we'd get a.b $in [ 1.0 ].

Currently, ABT translation and optimization transforms a singleton $in array into an Operations::Eq and extracts the value from the array. However, parameter binding in SBE stores all $in arrays as inListData (regardless of the size), and expects to use isMember to perform matching. We cannot compare an integer in a query predicate to an InListData member containing that element, so no matches are returned in the above case.

Proposed Fix: In Bonsai, bind a single value when parameterizing $in’s with singleton lists in bind_input_params.



 Comments   
Comment by Lynne Wang [ 04/Dec/23 ]

Fix for BF-31020 - for tests in upsert_fields.js to work as expected, an additional call to MatchExpression::optimize must be made in ListOfMatchExpression optimization (when $or becomes $in) on the generated InExpression.

Comment by Githook User [ 28/Nov/23 ]

Author:

{'name': 'Lynne Wang', 'email': 'lynne.wang@mongodb.com', 'username': 'lynne-wang'}

Message: SERVER-82979 Resolve inconsistency in ABT and SBE assumptions for duplicate predicates in $or
Branch: master
https://github.com/mongodb/mongo/commit/3cbf67aa94e9cc1fe9b6c67200dcdc17738c708b

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