[SERVER-42756] $multiply operator may return with or w/o an error depending on whether pipeline optimisation is enabled Created: 12/Aug/19  Updated: 29/Oct/23  Resolved: 26/Aug/19

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 3.6.17, 4.2.1, 4.3.1, 4.0.14

Type: Bug Priority: Major - P3
Reporter: Anton Korshunov Assignee: Anton Korshunov
Resolution: Fixed Votes: 0
Labels: afz, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Duplicate
is duplicated by SERVER-42151 $multiply with NaN operand violates c... Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2, v4.0, v3.6
Sprint: Query 2019-09-09
Participants:
Case:
Linked BF Score: 0

 Description   

When pipeline optimization is enabled, the arguments to the $multiply operator can be re-arranged. In certain cases, when one of the arguments is Infinity (or NaN), this re-arrangement may result in an error. But when the pipeline optimization is disabled, the very same query returns without an error.

For example,

db.col.insert({num: Infinity})
db.col.aggregate({$project: {a: {$multiply: [NumberDecimal(1), "$num"]}}})
2019-08-09T11:32:49.176+0100 E  QUERY    [js] Error: command failed: {
        "ok" : 0,
        "errmsg" : "Can't coerce out of range value inf to long",
        "code" : 31109,
        "codeName" : "Location31109"
}
db.adminCommand({configureFailPoint: 'disablePipelineOptimization', mode: 'alwaysOn'})
db.col.aggregate({$project: {a: {$multiply: [NumberDecimal(1), "$num"]}}})
{ "_id" : ObjectId("5d4d4ba7bf418d2f35ef7d3c"), "a" : NumberDecimal("Infinity") }



 Comments   
Comment by Githook User [ 10/Dec/19 ]

Author:

{'email': 'anton.korshunov@mongodb.com', 'name': 'Anton Korshunov', 'username': 'antkorsh'}

Message: SERVER-42756 $multiply with NaN operand violates commutativity

(cherry picked from commit aaa9874e04dbc2a4a33aeb7bfad9bee60f7145e0)
(cherry picked from commit 6729eaa16ca2794425fd90f034506e8d30a0cb5f)
Branch: v3.6
https://github.com/mongodb/mongo/commit/9803c2a3b02dada80cb846eb56b335d1d99825f7

Comment by Githook User [ 08/Nov/19 ]

Author:

{'username': 'antkorsh', 'email': 'anton.korshunov@mongodb.com', 'name': 'Anton Korshunov'}

Message: SERVER-42756 $multiply with NaN operand violates commutativity

(cherry picked from commit aaa9874e04dbc2a4a33aeb7bfad9bee60f7145e0)
(cherry picked from commit 6729eaa16ca2794425fd90f034506e8d30a0cb5f)
Branch: v4.0
https://github.com/mongodb/mongo/commit/fd49b082b075d6fbda620fcbafe2a822f667cffa

Comment by Githook User [ 29/Aug/19 ]

Author:

{'name': 'Anton Korshunov', 'username': 'antkorsh', 'email': 'anton.korshunov@mongodb.com'}

Message: SERVER-42756 Ensure that pipeline optimizations are re-enabled after test finishes

(cherry picked from commit 6729eaa16ca2794425fd90f034506e8d30a0cb5f)
Branch: v4.2
https://github.com/mongodb/mongo/commit/e6b47d17d68d96dd3bb0df7b82bfc4974511be51

Comment by Githook User [ 28/Aug/19 ]

Author:

{'name': 'Anton Korshunov', 'username': 'antkorsh', 'email': 'anton.korshunov@mongodb.com'}

Message: SERVER-42756 Ensure that pipeline optimizations are re-enabled after test finishes
Branch: master
https://github.com/mongodb/mongo/commit/6729eaa16ca2794425fd90f034506e8d30a0cb5f

Comment by Githook User [ 26/Aug/19 ]

Author:

{'name': 'Anton Korshunov', 'email': 'anton.korshunov@mongodb.com', 'username': 'antkorsh'}

Message: SERVER-42756 $multiply operator may return with or w/o an error depending on whether pipeline optimisation is enabled

(cherry picked from commit aaa9874e04dbc2a4a33aeb7bfad9bee60f7145e0)
Branch: v4.2
https://github.com/mongodb/mongo/commit/22d63982bdd3f99e07dcb69834960fb4042eba69

Comment by Githook User [ 26/Aug/19 ]

Author:

{'name': 'Anton Korshunov', 'email': 'anton.korshunov@mongodb.com', 'username': 'antkorsh'}

Message: SERVER-42756 $multiply operator may return with or w/o an error depending on whether pipeline optimisation is enabled
Branch: master
https://github.com/mongodb/mongo/commit/aaa9874e04dbc2a4a33aeb7bfad9bee60f7145e0

Comment by David Storch [ 12/Aug/19 ]

anton.korshunov, can you write a description for this ticket which explains the issue?

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