[SERVER-72075] Audit field ordering test coverage and create new jscore test if necessary Created: 13/Dec/22  Updated: 17/Jul/23  Resolved: 17/Jul/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Xuerui Fa Assignee: Backlog - Replication Team
Resolution: Won't Do Votes: 0
Labels: former-quick-wins
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Replication
Participants:

 Description   

In SERVER-30470, we discovered a bug where field ordering was not preserved when a specific series of oplog entries are applied. Although that bug was resolved after SERVER-50300, we should audit our tests to see if we have field ordering test coverage, and if not, we should create a new jscore test that covers this. The specific ordering of entries in SERVER-30470 that caused an issue was:

Starting with a document { _id: 1, a: 0 };
 
Apply: o: { $unset: { a: null } }
==> { _id: 1 };
Apply: o: { $set: { 'a.c': 1, b: null } }
==> { _id: 1, a: { c: 1 }, b: null };
 
// Applying the updates again:
Apply: o: { $unset: { a: null } }
==> { _id: 1, b: null };
Apply: o: { $set: { 'a.c': 1, b: null } }
==> { _id: 1, b: null, a: { c: 1 } };

This came out of a discussion for mongosync regarding field ordering test coverage



 Comments   
Comment by Brenda Rodriguez [ 17/Jan/23 ]

judah.schvimer@mongodb.com We discussed this at the Query Execution Triage. We think replication should do this or close it.

Comment by Max Hirschhorn [ 19/Dec/22 ]

We should confirm that dbhash produces different hashes for documents with different field orderings.

The dbHash command takes the md5sum of the bytes underlying the BSONObj. The md5sum of {_id: 0, a: 1, b: 2} is distinct from the md5sum of {_id: 0, b: 2, a: 1}.

rs:PRIMARY> db.mycoll.insert({_id: 0, a: 1, b: 2})
WriteResult({ "nInserted" : 1 })
rs:PRIMARY> db.mycoll2.insert({_id: 0, b: 2, a: 1})
WriteResult({ "nInserted" : 1 })
rs:PRIMARY> db.mycoll3.insert({_id: 0, a: 1, b: 2})
WriteResult({ "nInserted" : 1 })
rs:PRIMARY> db.runCommand({dbHash: 1})
{
        "collections" : {
                "mycoll" : "d956311cd2aaa9843158b5770d535447",
                "mycoll2" : "ea391c3e269ad9b03ea8bb7962a3ae3a",
                "mycoll3" : "d956311cd2aaa9843158b5770d535447"
        },

Comment by Judah Schvimer [ 19/Dec/22 ]

We should confirm that dbhash produces different hashes for documents with different field orderings.

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