[SERVER-84237] Incorrect $mod aggregation expression results Created: 15/Dec/23  Updated: 18/Jan/24  Resolved: 18/Jan/24

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

Type: Bug Priority: Major - P3
Reporter: Mindaugas Malinauskas Assignee: James Harrison
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Fix
Problem/Incident
is caused by SERVER-39336 In order to be schema friendly, $mod ... Closed
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

 

>db.c.insert({})
>db.c.aggregate([{$project:{value: {$mod: [ NumberLong("314159265358979393"), 58529]}}}])
Actual result: { "_id" : ObjectId("657c7e99af7f6fd9c0bf9a8f"), "value" : 31701 }
Expected result: { "_id" : ObjectId("657c7e99af7f6fd9c0bf9a8f"), "value" : 31702 }

 

Sprint: QO 2024-01-08, QO 2024-01-22
Participants:
Linked BF Score: 114

 Description   

SERVER-39336 attempts to make $mod expression output to depend only on input types. However, the patch suffers from correctness problems when one input is NumberLong another NumberDouble and NumberLong value cannot be represented as a 64-bit integer without precision loss in a 64-bit float-point number. In the BF,         $mod (NumberLong("314159265358979393"), NumberDouble(58529)) results in incorrect value 31701, when the correct value is 31702.



 Comments   
Comment by James Harrison [ 18/Jan/24 ]

Update and aggregation fuzzers should now permit the new behaviour in multiversion tests, (PR merged for DEVPROD-3725)

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