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

Commands should check for a collection before looking up a view

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.12
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Hide
      repro.js
      assert.writeOK(db.collection.insert( { x: 1 } ));
      assert.writeOK(db.system.views.insert( { _id: "bad", pipeline: "bad" } ));
      assert.commandWorked(db.collection.reIndex());
      

      The output:

      2016-08-17T22:21:45.942-0400 E QUERY    [thread1] Error: command failed: {
              "ok" : 0,
              "errmsg" : "found invalid view definition { _id: \"bad\", pipeline: \"bad\" } while reading 'test.system.views'",
              "code" : 182
      } : undefined :
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      doassert@src/mongo/shell/assert.js:13:14
      assert.commandWorked@src/mongo/shell/assert.js:264:5
      
      Show
      repro.js assert.writeOK(db.collection.insert( { x: 1 } )); assert.writeOK(db.system.views.insert( { _id: "bad" , pipeline: "bad" } )); assert.commandWorked(db.collection.reIndex()); The output: 2016-08-17T22:21:45.942-0400 E QUERY [thread1] Error: command failed: { "ok" : 0, "errmsg" : "found invalid view definition { _id: \"bad\", pipeline: \"bad\" } while reading 'test.system.views'", "code" : 182 } : undefined : _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:13:14 assert.commandWorked@src/mongo/shell/assert.js:264:5
    • Integration 2016-08-29
    • 0

      Commands that operate on collection namespaces should only call ViewCatalog::lookup() if Database::getCollection() returns nullptr. This avoids an unnecessary failure if a command is run on a valid collection namespace but the system.views collection contains an invalid view definition.

      In addition, we should probably not access the ViewCatalog if the namespace is virtualized.

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: