[SERVER-84130] Incorrect bucket-level filter optimization when some events in the bucket are missing the field Created: 13/Dec/23  Updated: 24/Jan/24  Resolved: 12/Jan/24

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

Type: Bug Priority: Major - P3
Reporter: Irina Yatsenko (Inactive) Assignee: Irina Yatsenko (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.2, v7.0, v6.0
Sprint: QI 2023-12-25, QI 2024-01-08
Participants:
Linked BF Score: 135

 Description   

db.createCollection("fuzzer_coll", {timeseries: {"timeField" : "time", "metaField" : "tag"}})
db.fuzzer_coll.insertMany([
     {_id: 0, time: new Date("2023-08-28T02:02:48.409Z"), tag: 0, val: 0},
     {_id: 1, time: new Date("2023-08-28T02:02:56.819Z"), tag: 0, obj: ISODate("2019-05-28T04:59:48.151Z")}, 
])
 
db.fuzzer_coll.aggregate([{$match: {$expr: {$gte: ["any string", "$obj"]}}}])
// returns nothing
 
db.adminCommand({configureFailPoint: 'disablePipelineOptimization', mode: 'alwaysOn'})
db.fuzzer_coll.aggregate([{$match: {$expr: {$gte: ["Refined revolutionize", "$obj"]}}}])
// returns: { "time" : ISODate("2023-08-28T02:02:48.409Z"), "tag" : 0, "_id" : 0, "val" : 0 }
// same result when running this query on a non-ts collection with the same 2 documents.

The bucket-level filter is

{"control.min.obj": {"$_internalExprLte" : "any string"}}

The problem is repro with other types, not just dates and strings, as long as the original expression in the filter isn't type-bracketing (such as comparisons inside $expr).



 Comments   
Comment by Irina Yatsenko (Inactive) [ 12/Jan/24 ]

I was mistaken to think that an update to etc/backports_required_for_multiversion_tests.yml is necessary.

Comment by Githook User [ 12/Jan/24 ]

Author:

{'name': 'Irina Yatsenko', 'email': '36858951+IrinaYatsenko@users.noreply.github.com', 'username': 'IrinaYatsenko'}

Message: SERVER-84130 Do not use bucket-level filter with non-type-bracketing LT(E) comparisons (#17620)

(cherry picked from commit eb7ce93bd252534d949f8f21716c0b3b9b0e0e0c)
Branch: v7.2
https://github.com/mongodb/mongo/commit/07c97453b23b13b2a93105be11a907d362d9fa19

Comment by Githook User [ 28/Dec/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-84130 Do not use bucket-level filter with non-type-bracketing LT(E) comparisons

GitOrigin-RevId: 62a527d28f70e01abbbea490ecea6c5155a6cbe5
Branch: v6.0
https://github.com/mongodb/mongo/commit/54b33b2468f6a61438ff5d9ba801d7f23d78c144

Comment by Githook User [ 28/Dec/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': '36858951+IrinaYatsenko@users.noreply.github.com', 'username': 'IrinaYatsenko'}

Message: SERVER-84130 Do not use bucket-level filter with non-type-bracketing LT(E) comparisons (#17620)

(cherry picked from commit eb7ce93bd252534d949f8f21716c0b3b9b0e0e0c)

GitOrigin-RevId: aff287699769336c780e1b4743539718fb2f62ef
Branch: v7.0
https://github.com/mongodb/mongo/commit/5f21bfcf8cabc0975fe44a91bfdcb674864d077e

Comment by Githook User [ 19/Dec/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': '36858951+IrinaYatsenko@users.noreply.github.com', 'username': 'IrinaYatsenko'}

Message: SERVER-84130 Do not use bucket-level filter with non-type-bracketing LT(E) comparisons (#17620)

GitOrigin-RevId: eb7ce93bd252534d949f8f21716c0b3b9b0e0e0c
Branch: master
https://github.com/mongodb/mongo/commit/c508fffdfeb0dc591fa9aea31efce6a46979811c

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