[SERVER-48684] Pipeline stage $set fails to set a non-existent dotted field to an object Created: 10/Jun/20  Updated: 29/Oct/23  Resolved: 01/Jul/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.0-rc9
Fix Version/s: 4.4.0-rc12, 4.7.0

Type: Bug Priority: Critical - P2
Reporter: Ruoxin Xu Assignee: Arun Banala
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-49310 Move computation for presence of an e... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Query 2020-06-29, Query 2020-07-13
Participants:

 Description   

This bug showed up when I was trying to run a multiversion update-fuzzer task against V4.4 and V4.2. On 4.2 we can set a non-existent dotted field to an object,

> db.fuzzer.aggregate([{$set: {"a.b": {a: 1}}}])
{ "_id" : ObjectId("5ee0a7bf3fe8d86b4e667fe5"), "a" : { "b" : { "a" : 1 } } }

But on 4.4 and master, this command would somehow result in a no-op. e.g.

> db.fuzzer.find()
{ "_id" : ObjectId("5edfd55b7e4f068196bef40e") }
 
> db.fuzzer.aggregate([{$set: {"a.b": {a: 1}}}])
{ "_id" : ObjectId("5edfd55b7e4f068196bef40e") }

Though we can still set a non-existent simple field to an object or set a dotted field to a simple non-object value on master. e.g.

> db.fuzzer.aggregate([{$set: {"a.b": 1}}])
{ "_id" : ObjectId("5edfd55b7e4f068196bef40e"), "a" : { "b" : 1 } }
 
> db.fuzzer.aggregate([{$set: {"a": {a: 1}}}])
{ "_id" : ObjectId("5edfd55b7e4f068196bef40e"), "a" : { "a" : 1 } }



 Comments   
Comment by David Storch [ 01/Jul/20 ]

arun.banala I've closed this with fixVersions 4.4.0-rc12 and 4.5.1 since it looks like the fix has been re-introduced into the master and v4.4 branches.

Comment by Githook User [ 01/Jul/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object

(cherry picked from commit d21425a2fe6d8179815ad22a8d0047fcaca84ae3)
Branch: v4.4
https://github.com/mongodb/mongo/commit/6c7c37470bdf4b9dc5ed0215ed161945f9553f0f

Comment by Githook User [ 30/Jun/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object

This reverts commit 847e085c0fb7621c4ed6947b45050f3d1b0cf886.
Branch: master
https://github.com/mongodb/mongo/commit/7c1e727bb5f087577d063e7b1b7a6696715f1900

Comment by Githook User [ 29/Jun/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: Revert "SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object"

This reverts commit f15e454fafcf369711f6da00ccdae5a2a4f8f0cd.
Branch: v4.4
https://github.com/mongodb/mongo/commit/fc6a12cad9b1aacb89edb1a25d81ce6005ed1077

Comment by Githook User [ 29/Jun/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: Revert "SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object"

This reverts commit 31499dd163068b6c70a1d2a072aaa9576a628ff0.
Branch: master
https://github.com/mongodb/mongo/commit/847e085c0fb7621c4ed6947b45050f3d1b0cf886

Comment by Githook User [ 26/Jun/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object

(cherry picked from commit 559406f9d52e96f3c10ac3be16c5890714adb2af)
Branch: v4.4
https://github.com/mongodb/mongo/commit/f15e454fafcf369711f6da00ccdae5a2a4f8f0cd

Comment by Githook User [ 26/Jun/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object
Branch: master
https://github.com/mongodb/mongo/commit/31499dd163068b6c70a1d2a072aaa9576a628ff0

Comment by Ian Boros [ 11/Jun/20 ]

Wow, nice find!

I wonder if in 4.4 the {a: 1} is part is being interpreted as a projection, where as 4.2 interprets it as a literal object.

 {"a.b": {a: 1}}

 

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