[SERVER-31894] Update operator $max with multiple fields can modify wrong array element in 3.6 Created: 09/Nov/17  Updated: 30/Oct/23  Resolved: 15/Nov/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.6.0-rc2
Fix Version/s: 3.6.0-rc5, 3.7.1

Type: Bug Priority: Major - P3
Reporter: Robert Guo (Inactive) Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: bkp, ufz
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
is related to SERVER-31821 Update operator $min handles non-exis... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: Query 2017-11-13, Query 2017-12-04
Participants:

 Description   

Repro:

db.test.insert({"x" : []});
db.test.update({}, {$max: {"x.2.a": 1, "x.2.b": 1}});
 
// 3.4: { "x" : [ null, null, { "a" : 1, "b" : 1 } ] }
// 3.6: { "x" : [ null, null, { "a" : 1 }, { "b" : 1 } ] }

The behavior on 3.6 gives the appearance that a different array element than the one specified was modified. In this case, the 3rd instead of the 2nd.

The behavior on 3.4 seems to be correct.



 Comments   
Comment by Githook User [ 15/Nov/17 ]

Author:

{'name': 'Tess Avitabile', 'username': 'tessavitabile', 'email': 'tess.avitabile@mongodb.com'}

Message: SERVER-31894 Update system should not use mutablebson::Element operator[](StringData name) for arrays

(cherry picked from commit 50521fcdcb57dad03b68d8ef070b970f227329cf)
Branch: v3.6
https://github.com/mongodb/mongo/commit/b879a2e2edbcf561636cf602c2dd3ae0ca647e94

Comment by Githook User [ 15/Nov/17 ]

Author:

{'name': 'Tess Avitabile', 'username': 'tessavitabile', 'email': 'tess.avitabile@mongodb.com'}

Message: SERVER-31894 Update system should not use mutablebson::Element operator[](StringData name) for arrays
Branch: master
https://github.com/mongodb/mongo/commit/50521fcdcb57dad03b68d8ef070b970f227329cf

Generated at Thu Feb 08 04:28:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.