[SERVER-42151] $multiply with NaN operand violates commutativity Created: 10/Jul/19  Updated: 19/Aug/19  Resolved: 19/Aug/19

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Claire Childs (Inactive) Assignee: Anton Korshunov
Resolution: Duplicate Votes: 0
Labels: afz, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-42756 $multiply operator may return with or... Closed
Operating System: ALL
Steps To Reproduce:

python buildscripts/resmoke.py --storageEngine wiredTiger --suites aggregation  repro_multiply.js 

repro_multiply.js

assert.commandWorked(db.my_coll.insert({}));
 
assert.throws(() => db.my_coll.aggregate(
[{                                                                             
    "$project": {                                                                        
        "a": {                                                                           
                "$multiply": [                                                           
                    NaN,                                                                 
                    {                                                                    
                        "$const": NumberDecimal("1")                                     
                    }                                                                    
                ]                                                                        
        },
        _id: 0                                                                                
    }                                                                                    
}]));
 
let res = db.my_coll.aggregate(
[{                                                                             
    "$project": {                                                                        
        "a": {                                                                           
                "$multiply": [                                                                                                                            
                    {                                                                    
                        "$const": NumberDecimal("1")                                     
                    },
                    NaN                                                                    
                ]                                                                        
        },
        _id: 0                                                                                
    }                                                                                    
}]);
assert.neq(res, null);

Sprint: Query 2019-08-26
Participants:

 Description   

When $multiply is evaluated, if an expression that evaluates to NaN is encountered first then the pipeline errors with the following message:

Error: command failed: {
   	"ok" : 0,
   	"errmsg" : "Failed to optimize pipeline :: caused by :: Can't coerce out of range value nan to long",
   	"code" : 31109,
   	"codeName" : "Location31109"
   } : aggregate failed

However if NaN is evaluated second, the command runs and returns results. This means that changing the order of the operands changes whether the command runs or errors, invalidating commutativity.



 Comments   
Comment by Anton Korshunov [ 19/Aug/19 ]

Closing as duplicate of SERVER-42756, it's the same issue.

Comment by Charlie Swanson [ 16/Aug/19 ]

anton.korshunov stumbled across a similar issue in a build failure recently. Looks like we might have a duplicate in SERVER-42756.

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