[SERVER-66570] Timeseries pushes down metaField-projections that can change semantics Created: 18/May/22  Updated: 29/Oct/23  Resolved: 14/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.7, 6.0.0-rc6
Fix Version/s: 5.0.15, 6.0.4, 6.2.0-rc0

Type: Bug Priority: Minor - P4
Reporter: Sam Mercier Assignee: Hana Pearlman
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-64102 $project field that references time-s... Closed
is related to SERVER-70940 Use internal names during stage reord... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.1, v6.0, v5.0
Participants:
Linked BF Score: 9

 Description   

If a projection computes `obj` only in terms of a meta field and another field `blergh` is computed in terms of value of `obj` IN THE SAME PROJECTION, then we will push down the meta-field-only computation of `obj`. This causes `obj` to be overwritten before we can compute `blergh` causing an incorrect calculation.

See the example below where `obj` is `obj` and `blergh` is `b`.

db.c.drop()
db.d.drop()
db.createCollection("c", {timeseries: {timeField: "t", metaField: "m"}})
db.c.insert({obj: {a: 3}, m: {}, t: new Date()})
db.d.insert({obj: {a: 3}, m: {}, t: new Date()})
 
db.d.aggregate([{$addFields: {obj: "$m", b: {$add: ["$obj.a", 1]}}}])
// Correct result { "_id" : ObjectId("6285641318f6a25daf333976"), "obj" : {  }, "m" : {  }, "t" : ISODate("2022-05-18T21:24:35.843Z"), "b" : 4 }
 
db.c.aggregate([{$addFields: {obj: "$m", b: {$add: ["$obj.a", 1]}}}])
// incorrect result { "t" : ISODate("2022-05-18T21:24:57.873Z"), "m" : {  }, "_id" : ObjectId("6285642918f6a25daf333978"), "obj" : {  }, "b" : null }



 Comments   
Comment by Githook User [ 05/Jan/23 ]

Author:

{'name': 'Hana Pearlman', 'email': 'hana.pearlman@mongodb.com', 'username': 'HanaPearlman'}

Message: SERVER-66570 : Ensure that pushed down projections computed from the metadata do not hide dependent subfields referenced in the same project
Branch: v5.0
https://github.com/mongodb/mongo/commit/2a8c711dcf0943ca639d23fc1d62ff449ef66dac

Comment by Githook User [ 05/Jan/23 ]

Author:

{'name': 'Hana Pearlman', 'email': 'hana.pearlman@mongodb.com', 'username': 'HanaPearlman'}

Message: SERVER-66570: Ensure that pushed down projections computed from the metadata do not hide dependent subfields referenced in the same project
Branch: v6.0
https://github.com/mongodb/mongo/commit/a3657539f4340d38b8d77058f588140904d2f81e

Comment by Githook User [ 14/Nov/22 ]

Author:

{'name': 'Hana Pearlman', 'email': 'hana.pearlman@mongodb.com', 'username': 'HanaPearlman'}

Message: SERVER-66570: Ensure that pushed down projections computed from the metadata do not hide dependent subfields referenced in the same project
Branch: master
https://github.com/mongodb/mongo/commit/0ec7e6199432904901a13bf82856074b1e4f4ab4

Comment by Ana Meza [ 19/May/22 ]

Assigning this one to you samuel.mercier@mongodb.com hoping you can have time for it cc'james.wahlin@mongodb.com 

Comment by James Wahlin [ 19/May/22 ]

This is very similar to SERVER-64102. Please review the patch for that fix when addressing this ticket.

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