[SERVER-58188] Inconsistency between the classic engine and SBE: {$mod: [-Infinity, NumberLong("0")]} Created: 01/Jul/21  Updated: 02/Jul/21  Resolved: 02/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.0-rc6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mohammad Dashti (Inactive) Assignee: Mindaugas Malinauskas
Resolution: Duplicate Votes: 0
Labels: sbe-rollout
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-57321 $mod match expression incorrectly han... Closed
Operating System: ALL
Sprint: Query Execution 2021-07-12
Participants:
Linked BF Score: 28

 Description   

Based on BF-21717, here's a minimal example to reproduce the issue:

> db.col.drop();
true
> db.col.insert({_id: 590, "obj": {_id: 595, "obj": {_id: 596, "num": Infinity }, }, });
WriteResult({ "nInserted" : 1 })
> db.col.find();
{ "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
> // using the classic engine
> db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: false})
{ "was" : true, "ok" : 1 }
> db.col.aggregate([{$match: {"obj.obj.num": {$mod: [-Infinity, NumberLong("0")]}}}]);
{ "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
> // using SBE
> db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: true})
{ "was" : false, "ok" : 1 }
> db.col.aggregate([{$match: {"obj.obj.num": {$mod: [-Infinity, NumberLong("0")]}}}]);
>

Even if you change -Infinity with Infinity in the above query, result is the same:

> db.col.drop();
true
> db.col.insert({_id: 590, "obj": {_id: 595, "obj": {_id: 596, "num": Infinity }, }, });
WriteResult({ "nInserted" : 1 })
> db.col.find();
{ "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
> // using the classic engine
> db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: false})
{ "was" : true, "ok" : 1 }
> db.col.aggregate([{$match: {"obj.obj.num": {$mod: [Infinity, NumberLong("0")]}}}]);
{ "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
> // using SBE
> db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: true})
{ "was" : false, "ok" : 1 }
> db.col.aggregate([{$match: {"obj.obj.num": {$mod: [Infinity, NumberLong("0")]}}}]);
> 

As you see in the above example, the classic engine considers the result of either {$mod: [-Infinity, NumberLong("0")]} or {$mod: [Infinity, NumberLong("0")]} to be Infinity. However, SBE does not match the result of either {$mod: [-Infinity, NumberLong("0")]} or {$mod: [Infinity, NumberLong("0")]} with Infinity. That's why, the classic engine passes the tuple through its filter, but SBE doesn't do the same. It's best if we could fix either of these engine to avoid this difference. This difference is specially annoying in the fuzzer tests, but not sure about its impact on the real-world scenarios.


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