[SERVER-21647] $rename changes field ordering Created: 24/Nov/15  Updated: 17/Nov/16  Resolved: 30/Dec/15

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.11, 3.0.7, 3.2.0-rc3
Fix Version/s: 2.6.12, 3.0.9, 3.2.3, 3.3.0

Type: Bug Priority: Major - P3
Reporter: Robert Guo (Inactive) Assignee: David Storch
Resolution: Done Votes: 2
Labels: code-and-test, fuzzer-blocker
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-21648 resmoke.py's dbHash should compare do... Closed
is related to SERVER-21613 Add CheckReplDBHash resmoke hook to j... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Sprint: QuInt E (01/11/16)
Participants:
Linked BF Score: 0

 Description   

A $rename is replicated as a $set and a $unset, which results in the same document but with the fields in a different order.

This causes dbHash to be different on the secondary and primary.



 Comments   
Comment by Githook User [ 11/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 add missing $rename unit test

(cherry picked from commit b45dba8425b49714c5ca1394aba0bb97029c2560)
Branch: v3.2
https://github.com/mongodb/mongo/commit/54a7b59d3eb99dce40357688bd5427314d8569f7

Comment by Githook User [ 11/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 fix $rename to not re-order fields when the destination field is already present

(cherry picked from commit 994060e622c22783c29ff3d1c243c298fcd3442c)
Branch: v3.2
https://github.com/mongodb/mongo/commit/212c55a9863eee6f9a5d452961bbfeffc80ab9dd

Comment by Githook User [ 07/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 add missing $rename unit test

(cherry picked from commit b45dba8425b49714c5ca1394aba0bb97029c2560)

Conflicts:
src/mongo/db/ops/modifier_rename_test.cpp
Branch: v2.6
https://github.com/mongodb/mongo/commit/1761ef4bcd84fc4d032bb862acef9ae8a05f5610

Comment by Githook User [ 07/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 fix $rename to not re-order fields when the destination field is already present

(cherry picked from commit 994060e622c22783c29ff3d1c243c298fcd3442c)

Conflicts:
src/mongo/bson/mutable/document.cpp
src/mongo/bson/mutable/element.h
src/mongo/bson/mutable/mutable_bson_test.cpp
src/mongo/db/ops/modifier_rename.cpp
src/mongo/db/ops/modifier_rename_test.cpp
Branch: v2.6
https://github.com/mongodb/mongo/commit/0f7a20e03c7f39e45e99d12e6e74a62d82ce7f64

Comment by Githook User [ 06/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 add missing $rename unit test

(cherry picked from commit b45dba8425b49714c5ca1394aba0bb97029c2560)
Branch: v3.0
https://github.com/mongodb/mongo/commit/89b5c11f9363e15aa590abf59350b6a7630e7367

Comment by Githook User [ 06/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 fix $rename to not re-order fields when the destination field is already present

(cherry picked from commit 994060e622c22783c29ff3d1c243c298fcd3442c)
Branch: v3.0
https://github.com/mongodb/mongo/commit/eb64fca87952caa030fefd06c1090cdeef6ef12f

Comment by Githook User [ 30/Dec/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 add missing $rename unit test
Branch: master
https://github.com/mongodb/mongo/commit/b45dba8425b49714c5ca1394aba0bb97029c2560

Comment by Githook User [ 30/Dec/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-21647 fix $rename to not re-order fields when the destination field is already present
Branch: master
https://github.com/mongodb/mongo/commit/994060e622c22783c29ff3d1c243c298fcd3442c

Comment by Eric Milkie [ 11/Dec/15 ]

From the examples, I was confused by the original title of this ticket. $rename isn't changing the field order on secondaries – in fact, the field order is properly preserved on secondaries. On primaries and standalone nodes, however, the $rename-d field is moved to the end of the object, regardless of the prior name or the new name of the renamed field. If we want $rename to work like $set and other $ modifiers, it ought to preserve the field order. This can be fixed by rebuilding the object on the primary to insert the renamed field in the proper place.

Comment by Robert Guo (Inactive) [ 24/Nov/15 ]

primary log:

[ReplicaSetFixture:job0:primary] 2015-11-23T19:29:45.050-0500 I WRITE    [conn11] update test.test update: { $rename: { a: "b"} } keysExamined:0 docsExamined:1 nMatched:1 nModified:1 keyUpdates:0 writeConflicts:0 numYields:0 locks:{ Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, Metadata: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } } 0ms

primary oplog:

{ "ts" : Timestamp(1448324985, 1), "t" : NumberLong(1), "h" : NumberLong("-6849103603646650374"), "v" : 2, "op" : "u", "ns" : "test.test", "o2" : { "_id" : 0 }, "o" : { "$set" : { "b" : 1 }, "$unset" : { "a" : true } } }

secondary oplog:

{ "ts" : Timestamp(1448324985, 1), "t" : NumberLong(1), "h" : NumberLong("-6849103603646650374"), "v" : 2, "op" : "u", "ns" : "test.test", "o2" : { "_id" : 0 }, "o" : { "$set" : { "b" : 1 }, "$unset" : { "a" : true } } }

document on primary

{ "_id" : 0, "c" : 2, "b" : 1 }

document on secondary:

{ "_id" : 0, "b" : 1, "c" : 2 }

Comment by Scott Hernandez (Inactive) [ 24/Nov/15 ]

Is the oplog for the first update a $unset + $set?

Can you supply the oplog entries and the document on the replica please?

Generated at Thu Feb 08 03:57:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.