[SERVER-84369] Ineligible query reuses plan cache entry for a COUNT_SCAN (SBE only) Created: 21/Dec/23  Updated: 11/Jan/24  Resolved: 09/Jan/24

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

Type: Bug Priority: Major - P3
Reporter: Alya Berciu Assignee: Ruoxin Xu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.2, v7.1
Sprint: QO 2023-12-25, QO 2024-01-08, QO 2024-01-22
Participants:
Linked BF Score: 135

 Description   

See BF-31072 for a detailed description/repro of the problem. The following pipeline (A) is ineligible for a COUNT_SCAN:
 

[{ $match: {"num": {$not: {$gt: NumberDecimal("9.999999999999999999999999999999999E+6144")}}} },
{$count: "num"}]

However, when this pipeline (B) runs first:

[{$match: {"num": {$not: {$gt: NumberDecimal("Infinity")}}}},        {$count: "num"}]

B uses a COUNT_SCAN, and generates a plan-cache entry, which A then (incorrectly) uses. Both queries should match/count an empty document {}; however, B does not count it when using a COUNT_SCAN.

This is only reproducible with SBE enabled, plan cache on, and match expression optimization enabled.
 



 Comments   
Comment by Githook User [ 11/Jan/24 ]

Author:

{'name': 'Ruoxin Xu', 'email': 'ruoxin.xu@mongodb.com', 'username': 'RuoxinXu'}

Message: SERVER-84369 Avoid auto-parameterizing the infinity value in a query (#17867)

(cherry picked from commit 99853e7a9c71d793b5b3c5028e322bf0215d2697)
Branch: v7.2
https://github.com/mongodb/mongo/commit/1267d6ba5caf3335fa894dda597bab07ebb4f594

Comment by Githook User [ 09/Jan/24 ]

Author:

{'name': 'Ruoxin Xu', 'email': 'ruoxin.xu@mongodb.com', 'username': 'RuoxinXu'}

Message: SERVER-84369 Avoid auto-parameterizing the infinity value in a query (#17867)

GitOrigin-RevId: 99853e7a9c71d793b5b3c5028e322bf0215d2697
Branch: master
https://github.com/mongodb/mongo/commit/14730fb0a89e0091909604419b40e1c0d3c31702

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