Operational Defect Database

BugZero found this defect 76 days ago.

MongoDB | 2598053

$bucketAuto $mergeObject does not obey input order

Last update date:

3/15/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

No fixed releases provided.

Description:

Info

Problem The same cause as SERVER-85337. Previously, $bucketAuto had incorrect implementation to assume stable-sort works well with positional accumulators like $first and $last. SERVER-85337 fixes the issue by specializing $first/$firstN/$last/$lastN. $mergeObject is an escape goat only discovered recently after SERVER-81571 is merged and later revealed in fuzzer test failure BF-32056. Steps to reproduce db.c.insertMany([ { "_id" : 0, "a" : 0 }, { "_id" : 1, "a" : 1 }, { "_id" : 2, "a" : 2 }, { "_id" : 3, "a" : 3 }, { "_id" : 4, "a" : 4 }, { "_id" : 5, "a" : 5 }, { "_id" : 6, "a" : 6 }, { "_id" : 7, "a" : 7 }, { "_id" : 8, "a" : 8 }, { "_id" : 9, "a" : 9 }]); db.c.aggregate([ {$sort: {a: -1}}, {$bucket: {groupBy: "$a", boundaries: [0, 5, 10], output: {a: {$mergeObjects: "$$ROOT"}} }} ]); db.c.aggregate([ {$sort: {a: -1}}, {$bucketAuto: {groupBy: "$a", buckets: 2, output: {a: {$mergeObjects: "$$ROOT"}} }} ]); $bucket returns the results: { "_id" : 0, "a" : { "_id" : 0, "a" : 0 } } { "_id" : 5, "a" : { "_id" : 5, "a" : 5 } } Whereas $bucketAuto returns the results: { "_id" : { "min" : 0, "max" : 5 }, "a" : { "_id" : 4, "a" : 4 } } { "_id" : { "min" : 5, "max" : 9 }, "a" : { "_id" : 9, "a" : 9 } } Plan of attack Follow SERVER-85337 to specialize accumulator $mergeObject as well.

Top User Comments


Steps to Reproduce


Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

In Progress

Learn More

Search:

...