[SERVER-61679] $sum accumulator fails in aggregation_wildcard_fuzzer when numeric data set is mixed typed and precision is too wide Created: 21/Nov/21  Updated: 13/Jan/22  Resolved: 13/Jan/22

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

Type: Bug Priority: Major - P3
Reporter: Yoon Soo Kim Assignee: Yoon Soo Kim
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-62485 Match the SBE $add behavior to the cl... Closed
Related
is related to SERVER-58978 Determine narrowest type before compu... Closed
Operating System: ALL
Steps To Reproduce:

In one window, execute the following.

$ build/debug/install/bin/mongod --setParameter featureFlagSBEGroupPushdown=true

In another windows, execute the following.

$ build/debug/install/bin/mongo
MongoDB Enterprise > db.tt.drop();
true
MongoDB Enterprise > db.tt.insert([{n: NumberLong("9223372036854775807")}, {n: NumberDecimal("1.0")}]);
BulkWriteResult({
	"writeErrors" : [ ],
	"writeConcernErrors" : [ ],
	"nInserted" : 2,
	"nUpserted" : 0,
	"nMatched" : 0,
	"nModified" : 0,
	"nRemoved" : 0,
	"upserted" : [ ]
})
MongoDB Enterprise > db.tt.aggregate([{$group: {_id: null, num : {$sum: {$add: [NumberLong("1000"), "$n"]}}}}]);
{ "_id" : null, "num" : NumberDecimal("9223372036854777808.0") }
MongoDB Enterprise > db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: true});
{ "was" : false, "ok" : 1 }
MongoDB Enterprise > db.tt.aggregate([{$group: {_id: null, num : {$sum: {$add: [NumberLong("1000"), "$n"]}}}}]);
{ "_id" : null, "num" : NumberDecimal("9223372036854776809.0") }

Sprint: QE 2021-11-29, QE 2021-12-13, QE 2021-12-27, QE 2022-01-10, QE 2022-01-24
Participants:

 Description   

As can be seen in the attached repro script, when a numeric data set is mixed-typed and the precision is too wide so that int64 can't express any intermediate result, the SBE engine result does not agree with the classic engine result. Results are...

MongoDB Enterprise > db.tt.aggregate([{$group: {_id: null, num : {$sum: {$add: [NumberLong("1000"), "$n"]}}}}]);
{ "_id" : null, "num" : NumberDecimal("9223372036854777808.0") }
MongoDB Enterprise > db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: true});
{ "was" : false, "ok" : 1 }
MongoDB Enterprise > db.tt.aggregate([{$group: {_id: null, num : {$sum: {$add: [NumberLong("1000"), "$n"]}}}}]);
{ "_id" : null, "num" : NumberDecimal("9223372036854776809.0") }



 Comments   
Comment by Eric Cox (Inactive) [ 05/Jan/22 ]

yoonsoo.kim We were discussing if we should just relax the fuzzer when the result is over some very large threshold in terms of significant digits? Thoughts?

Comment by Mihai Andrei [ 23/Nov/21 ]

yoonsoo.kim Yes; at a glance, this looks to be the same issue because the same scenario seems to be happening: we're adding MAX_LONG to a decimal and the sum is losing precision in the classic engine.

Comment by Yoon Soo Kim [ 22/Nov/21 ]

mihai.andrei kyle.suarez Do you think this issue is same as SERVER-58978?

Comment by Yoon Soo Kim [ 22/Nov/21 ]

Actually, the SBE engine is better to keep the precision.

Comment by Yoon Soo Kim [ 22/Nov/21 ]

This issue may be a dup of SERVER-58978

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