[SERVER-26894] validate_collections.js should tolerate InvalidViewDefinition when doing findOne() on admin.system.version collection Created: 03/Nov/16  Updated: 19/Nov/16  Resolved: 09/Nov/16

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.4.0-rc3

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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

Sprint: TIG 2016-11-21
Participants:
Linked BF Score: 0

 Description   

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.



 Comments   
Comment by Githook User [ 09/Nov/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-26894 Tolerate invalid views in validate_collections.js.
Branch: master
https://github.com/mongodb/mongo/commit/1774b8751bbd9edc31bd468ea4d37ba41653031c

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