[SERVER-27813] Change ReplSetTest's checkDBHashesForReplSet() function to handle duplicate namespaces being returned Created: 25/Jan/17  Updated: 05/Apr/17  Resolved: 21/Feb/17

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

Type: Task Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Jonathan Abrahams
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-28065 blacklist jstests/core/views/duplicat... Closed
Backwards Compatibility: Fully Compatible
Sprint: TIG 2017-03-06
Participants:
Linked BF Score: 0

 Description   

There is a case where the "listCollections" command can return two info objects for the same namespace if a client writes directly to the system.views collection. This scenario causes ReplSetTest's checkDBHashesForReplSet() function to throw an error because it'll find the options differ when comparing the options of the "test.myns" collection to the "test.myns" view. Adding the clause && secondaryInfo.type === primaryInfo.type to this line and throwing an error if no match for the (name, type) combination is found allows the data consistency checks we perform after running our tests to tolerate this scenario.

Credit to robert.guo for this idea as opposed to removing the ability for the fuzzer to write directly to the system.views collection.


assert.commandWorked(db.runCommand({create: "myns"}));
assert.writeOK(db.system.views.insert({
    _id: db.getName() + ".view",
    viewOn: "coll",
    pipeline: [],
}));
 
printjson(db.getCollectionInfos());

Output

[
    {
        "name" : "myns",
        "type" : "collection",
        "options" : {
 
        },
        "info" : {
            "readOnly" : false
        },
        "idIndex" : {
            "v" : 2,
            "key" : {
                "_id" : 1
            },
            "name" : "_id_",
            "ns" : "test.myns"
        }
    },
    {
        "name" : "myns",
        "type" : "view",
        "options" : {
            "viewOn" : "coll",
            "pipeline" : [ ]
        },
        "info" : {
            "readOnly" : true
        }
    },
    {
        "name" : "system.views",
        "type" : "collection",
        "options" : {
 
        },
        "info" : {
            "readOnly" : false
        },
        "idIndex" : {
            "v" : 2,
            "key" : {
                "_id" : 1
            },
            "name" : "_id_",
            "ns" : "test.system.views"
        }
    }
]



 Comments   
Comment by Githook User [ 21/Feb/17 ]

Author:

{u'username': u'hptabster', u'name': u'Jonathan Abrahams', u'email': u'jonathan@mongodb.com'}

Message: SERVER-27813 Change ReplSetTest's checkDBHashesForReplSet() function to handle duplicate namespaces being returned
Branch: master
https://github.com/mongodb/mongo/commit/04de5dedaf811f24e0af3f174608a767dac5c4e9

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