Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27813

Change ReplSetTest's checkDBHashesForReplSet() function to handle duplicate namespaces being returned

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.4
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • None
    • Fully Compatible
    • TIG 2017-03-06
    • 0

      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"
              }
          }
      ]
      

            Assignee:
            jonathan.abrahams Jonathan Abrahams
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: