[SERVER-32109] $rename does not update value if existing "to" field has the same numeric value but different type. Created: 29/Nov/17  Updated: 30/Oct/23  Resolved: 13/Dec/17

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

Type: Bug Priority: Minor - P4
Reporter: Robert Guo (Inactive) Assignee: Justin Seyster
Resolution: Fixed Votes: 0
Labels: ufz
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: Query 2017-12-04, Query 2017-12-18
Participants:

 Description   

On 3.6, a $rename operator applied to a destination field that already exists, and has the same value as the source field, will not update that field. On 3.4, the field type is changed as expected.

db.test.insert({to:NumberLong(100), from:100});
db.test.update({},{$rename:{from:"to"}});
db.test.findOne()
// 3.6: { "to" : NumberLong(100) }
// 3.4: { "to" : 100 }



 Comments   
Comment by Githook User [ 13/Dec/17 ]

Author:

{'name': 'Justin Seyster', 'email': 'justin.seyster@mongodb.com', 'username': 'jseyster'}

Message: SERVER-32109 RenameNode no longer checks for no-op set.

Before this change, a {$rename: {from: "to"}} would check to see if
the "from" and "to" values were identical, allowing it to elide the
{$set: {to: <value-of-from-field>}} portion of the oplog update
entry. The equality check we used was not exact, however, resulting in
potentially incorrect results from $rename in edge cases.

We could use a precise equality check, but it's more expensive. More
likely than not, it's cheaper to just include the $set in the oplog
update for every $rename, so that's what we do now.

(cherry picked from commit 4d53b4beb00eaa341bf2a134fbc9366d3333e830)
Branch: v3.6
https://github.com/mongodb/mongo/commit/1a81fbea1aaa09ad79b52c0fd5ad808f067e6acf

Comment by Githook User [ 13/Dec/17 ]

Author:

{'name': 'Justin Seyster', 'email': 'justin.seyster@mongodb.com', 'username': 'jseyster'}

Message: SERVER-32109 RenameNode no longer checks for no-op set.

Before this change, a {$rename: {from: "to"}} would check to see if
the "from" and "to" values were identical, allowing it to elide the
{$set: {to: <value-of-from-field>}} portion of the oplog update
entry. The equality check we used was not exact, however, resulting in
potentially incorrect results from $rename in edge cases.

We could use a precise equality check, but it's more expensive. More
likely than not, it's cheaper to just include the $set in the oplog
update for every $rename, so that's what we do now.
Branch: master
https://github.com/mongodb/mongo/commit/4d53b4beb00eaa341bf2a134fbc9366d3333e830

Comment by David Storch [ 29/Nov/17 ]

Great find, robert.guo. Another gem from the generational fuzzer I presume?

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