Operational Defect Database

BugZero found this defect 207 days ago.

MongoDB | 2483140

$project incorrectly pushed down on timeseries when $project uses $getField on a measurement field

Last update date:

3/12/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

7.3.0-rc0

7.2.0-rc2

7.0.5

6.0.13

5.0.24

Description:

Info

$project, $addFields and $set that reference the metaField are pushed before the $_internalUnpackBucket stage. However, we are not accounting for the case that these stages could have expressions with subexpressions that are dependent on measurement fields. Below is a minimal repro from a fuzzer BF.

Top User Comments

xgen-internal-githook commented on Thu, 30 Nov 2023 21:26:13 +0000: Author: {'name': 'Gil Alon', 'email': 'gil.alon@mongodb.com', 'username': 'galon1'} Message: SERVER-82447 Restrict project and addFields pushdown before unpack if an expression depends on the whole document (cherry picked from commit 16e742346bf0d4a58419920663695128c5add72a) GitOrigin-RevId: 583601f9a0684c97a52ed8acf7b1b925126f4bc5 Branch: v5.0 https://github.com/mongodb/mongo/commit/116bd5ff632eca17d80d563fda8fc63e928d6ac4 xgen-internal-githook commented on Wed, 29 Nov 2023 22:27:09 +0000: Author: {'name': 'Gil Alon', 'email': 'gil.alon@mongodb.com', 'username': 'galon1'} Message: SERVER-82447 Restrict project and addFields pushdown before unpack if an expression depends on the whole document Branch: v6.0 https://github.com/mongodb/mongo/commit/16e742346bf0d4a58419920663695128c5add72a xgen-internal-githook commented on Tue, 28 Nov 2023 19:03:39 +0000: Author: {'name': 'Gil Alon', 'email': 'gil.alon@mongodb.com', 'username': 'galon1'} Message: SERVER-82447 Restrict project and addFields pushdown before unpack if an expression depends on the whole document Branch: v7.0 https://github.com/mongodb/mongo/commit/9810bf55855b2c1ae725fba91dc0775f6015be6b xgen-internal-githook commented on Fri, 17 Nov 2023 20:45:32 +0000: Author: {'name': 'Gil Alon', 'email': 'gil.alon@mongodb.com', 'username': 'galon1'} Message: SERVER-82447 Restrict project and addFields pushdown before unpack if an expression depends on the whole document (cherry picked from commit 0d000e66178ce2e1c4a25da246d662e4939ac179) Branch: v7.2 https://github.com/mongodb/mongo/commit/a9d61291ebc811bda860814a6bd839549c087193 xgen-internal-githook commented on Wed, 15 Nov 2023 19:18:40 +0000: Author: {'name': 'Gil Alon', 'email': 'gil.alon@mongodb.com', 'username': 'galon1'} Message: SERVER-82447 Restrict project and addFields pushdown before unpack if an expression depends on the whole document Branch: master https://github.com/mongodb/mongo/commit/0d000e66178ce2e1c4a25da246d662e4939ac179

Steps to Reproduce

assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: 'time', metaField: 'tag'}})); assert.commandWorked(coll.insert({ _id:1, time: new Date("2022-12-25T00:25:56.333Z"), tag:2, obj:3})); // run aggregation coll.aggregate([ {$project: {"array": {$map: {input: ["$tag"], in: {$getField: "obj"}}}}}]) // aggregation returns [ { "_id" : 1, "array" : [ null ] } ] // but the aggregation should return[[ { "_id" : 1, "array" : [ 3 ] } ]]

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Closed

Learn More

Search:

...