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

validate_collections.js should tolerate InvalidViewDefinition when doing findOne() on admin.system.version collection

    • Fully Compatible
    • ALL
    • Hide
      python buildscripts/resmoke.py --executor=jstestfuzz repro_server26894.js
      
      repro_server26894.js
      var myDB = db.getSiblingDB('admin');
      myDB.dropDatabase();
      myDB["system.views"].insertOne({invalid: new NumberLong(1000)});
      
      Output
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.063-0400 2016-11-03T10:41:26.063-0400 E QUERY    [main] Error: error: {
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400  "ok" : 0,
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400  "errmsg" : "found invalid view definition _id: ObjectId('581b4c95b833305205e28c7f') while reading 'admin.system.views'",
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400  "code" : 182,
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400  "codeName" : "InvalidViewDefinition"
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400 } :
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 _getErrorWithCode@src/mongo/shell/utils.js:25:13
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBCommandCursor@src/mongo/shell/query.js:702:1
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBQuery.prototype._exec@src/mongo/shell/query.js:117:28
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBQuery.prototype.hasNext@src/mongo/shell/query.js:288:5
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBCollection.prototype.findOne@src/mongo/shell/collection.js:294:10
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 getFeatureCompatibilityVersion@jstests/hooks/validate_collections.js:17:19
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 validateCollections@jstests/hooks/validate_collections.js:43:47
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 @jstests/hooks/run_validate_collections.js:32:18
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 @jstests/hooks/run_validate_collections.js:5:2
      [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 failed to load: jstests/hooks/run_validate_collections.js
      
      Show
      python buildscripts/resmoke.py --executor=jstestfuzz repro_server26894.js repro_server26894.js var myDB = db.getSiblingDB( 'admin' ); myDB.dropDatabase(); myDB[ "system.views" ].insertOne({invalid: new NumberLong(1000)}); Output [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.063-0400 2016-11-03T10:41:26.063-0400 E QUERY [main] Error: error: { [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400 "ok" : 0, [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400 "errmsg" : "found invalid view definition _id: ObjectId('581b4c95b833305205e28c7f') while reading 'admin.system.views'", [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400 "code" : 182, [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400 "codeName" : "InvalidViewDefinition" [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.064-0400 } : [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 _getErrorWithCode@src/mongo/shell/utils.js:25:13 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBCommandCursor@src/mongo/shell/query.js:702:1 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBQuery.prototype._exec@src/mongo/shell/query.js:117:28 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBQuery.prototype.hasNext@src/mongo/shell/query.js:288:5 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 DBCollection.prototype.findOne@src/mongo/shell/collection.js:294:10 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.065-0400 getFeatureCompatibilityVersion@jstests/hooks/validate_collections.js:17:19 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 validateCollections@jstests/hooks/validate_collections.js:43:47 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 @jstests/hooks/run_validate_collections.js:32:18 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 @jstests/hooks/run_validate_collections.js:5:2 [ValidateCollections:job0:repro_server26894:ValidateCollections] 2016-11-03T10:41:26.066-0400 failed to load: jstests/hooks/run_validate_collections.js
    • TIG 2016-11-21
    • 0

      The getFeatureCompatibilityVersion() function in validate_collections.js does a findOne() on the admin.system.version collection rather than {getParameter: 1, featureCompatibilityVersion: 1} in order to be able to read the featureCompatibilityVersion from the config servers when running in a sharded cluster.

      function getFeatureCompatibilityVersion(adminDB) {
          var res = adminDB.system.version.findOne({_id: "featureCompatibilityVersion"});
          if (res === null) {
              return "3.2";
          }
          return res.version;
      }
      

      The view catalog of the admin database is only resolved when the admin.system.version collection doesn't exist. We can therefore interpret the featureCompatibilityVersion as 3.2 when the findOne() operation fails with InvalidViewDefinition. The error should only be handled in this fashion when skipValidationOnInvalidViewDefinitions is set to true.

      Additionally, the filter to the "listCollections" command should be changed to

      {$or: [{type: "collection"}, {type: {$exists: false}}]}

      to avoid resolving the view catalog when skipValidationOnInvalidViewDefinitions is set to true.

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

              Created:
              Updated:
              Resolved: