[SERVER-60584] Write a test to ensure SBE's implementation of multiply succeeds in edge cases Created: 08/Oct/21  Updated: 29/Oct/23  Resolved: 27/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0, 5.1.0-rc3

Type: Task Priority: Major - P3
Reporter: Jennifer Peshansky (Inactive) Assignee: Jennifer Peshansky (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-60588 $multiply incorrectly throws an error... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.1
Sprint: QE 2021-10-18, QE 2021-11-01
Participants:

 Description   

This is a follow-up to BF-22891. It seems that this is actually a classic engine bug and SERVER-60588 will permanently fix the issue, but we want to write a test to see if there are any other bugs in SBE's implementation of $multiply that we don't know about. We should be able to run this test in both the classic and SBE engines and get the same results.

We could try calling $multiply with 2 args and 3 args with every possible combination of types. We should test very small and very large values: 1, 2^32, 2^32-1, -1, as well as the limits of each of the types that may cause an overflow.

Here's a repro of one failure, the one that occurred in the original BF:
> db.fuzzer_coll.drop();
> db.fuzzer_coll.insert([{_id: 13}, {_id: 14, num: 1}]);
> db.fuzzer_coll.aggregate([{$sort: {_id: 1}}, {$limit: 20}, {$graphLookup: {from: "fuzzer_coll", startWith: {$filter: {input: "$array", cond: {$or: []}}}, connectFromField: "nonexistent", connectToField: "nonexistent", as: "array", restrictSearchWithMatch: {$expr: {$multiply: ["$num", NumberLong("314159265358979393"), NumberLong("-314159265358979323")]}}}}]);

In the v5.1 shell, this results in:
{ "_id" : 13, "array" : [ { "_id" : 14, "num" : 1 } ] }
{ "_id" : 14, "num" : 1, "array" : [ { "_id" : 14, "num" : 1 } ] }

In the v5.0 shell, however, it triggers an error: "Can't coerce out of range value -9.8696e+34 to long."



 Comments   
Comment by Githook User [ 01/Nov/21 ]

Author:

{'name': 'Jennifer Peshansky', 'email': 'jennifer.peshansky@mongodb.com', 'username': 'jenniferpeshansky'}

Message: SERVER-60584 Add test cases for $multiply
Branch: v5.1
https://github.com/mongodb/mongo/commit/bb38d819d64e8148ae6dbe0bf659556459f4f076

Comment by Githook User [ 27/Oct/21 ]

Author:

{'name': 'Jennifer Peshansky', 'email': 'jennifer.peshansky@mongodb.com', 'username': 'jenniferpeshansky'}

Message: SERVER-60584 Add test cases for $multiply
Branch: master
https://github.com/mongodb/mongo/commit/b7a055f55a202ba870730fb865579acf5d9fb90f

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