[SERVER-28271] invalid_system_views.js test cases may pass for the wrong reason Created: 10/Mar/17  Updated: 07/Sep/17  Resolved: 12/Apr/17

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

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: James Wahlin
Resolution: Done Votes: 0
Labels: bkp, neweng, read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-28121 DurableViewCatalog shouldn't throw on... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.4
Sprint: Query 2017-04-17
Participants:

 Description   

The test cases exercised by invalid_system_views.js may be passing for the wrong reason. They are missing the following elements, each of which will make the view definition invalid, regardless of conditions we want to test.

  1. The namespace represented by the '_id' field should be the full namespace, with view name prefixed by the database name and '.' character.
  2. A 'viewOn' field must be provided specifying the collection or view this view is being built on.


 Comments   
Comment by Githook User [ 28/Apr/17 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-28271 Improve handling of invalid view pipeline defs

(cherry picked from commit b5e2615f9cf29942783ed554afeb364052dd83a4)
Branch: v3.4
https://github.com/mongodb/mongo/commit/858a26bfa16bf0904fe5776e219f8f00b5d864e6

Comment by Githook User [ 12/Apr/17 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-28271 Improve handling of invalid view pipeline defs
Branch: master
https://github.com/mongodb/mongo/commit/b5e2615f9cf29942783ed554afeb364052dd83a4

Comment by James Wahlin [ 11/Apr/17 ]

david.storch - there are currently nothing in place that prevents users from inserting an invalid view definition directly into the db.system.views collection. We couldn't ban direct insertion, as it would impact replication of view definitions. Given this a decision was made to allow startup with invalid views, making it possible to remove / correct the invalid view entries. When an invalid entry is found we skip loading the view catalog for the given database and print a warning in the mongod log.

Comment by David Storch [ 11/Apr/17 ]

james.wahlin, why is it correct to skip over invalid view definitions rather than fail to start up? In general I would think that mongod would fail to start when we find something invalid or unexpected in the catalog metadata.

Comment by James Wahlin [ 10/Apr/17 ]

In fixing one of the test cases I found a scenario where an invalid view entry can cause mongod to abort on startup:

db.system.views.insert({_id: "test.view", viewOn: "test", pipeline: [1]})

I will add handling for this and any other scenarios found. Proper behavior when encountering an invalid view definition is to skip loading the view catalog for the given database, but allow mongod to start.

Comment by James Wahlin [ 10/Mar/17 ]

In addition to fixing the existing tests, we should add new tests for:

  1. Missing database + '.' prefix in the _id field
  2. Missing viewOn field
Generated at Thu Feb 08 04:17:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.