listCollections should not return an InvalidViewDefinition error when 'filter' is {type: 'collection'}

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Storage
    • None
    • Storage Execution
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Reproducer:

      diff --git a/jstests/core/list_collections_no_views.js b/jstests/core/list_collections_no_views.js
      index ed2c1b95d0..172b3694e5 100644
      --- a/jstests/core/list_collections_no_views.js
      +++ b/jstests/core/list_collections_no_views.js
      @@ -47,7 +47,7 @@ assert.eq(allExpected,
       // {type: {$exists: false}} is needed for versions <= 3.2
       let collOnlyCommand = {
           listCollections: 1,
      -    filter: {$or: [{type: 'collection'}, {type: {$exists: false}}]}
      +    filter: {type: 'collection'} //{$or: [{type: 'collection'}, {type: {$exists: false}}]}
       };
      
       let collOnly = mydb.runCommand(collOnlyCommand);
      @@ -108,7 +108,7 @@ assert.eq(viewOnlyExpected,
       let views = mydb.getCollection('system.views');
       views.insertOne({invalid: NumberLong(1000)});
      
      -let collOnlyInvalidView = mydb.runCommand(collOnlyCommand);
      +let collOnlyInvalidView = assert.commandWorked(mydb.runCommand(collOnlyCommand));
       assert.eq(collOnlyExpected,
                 collOnlyInvalidView.cursor.firstBatch
                     .map(function(c) {
      

      Test failure:

      python3 buildscripts/resmoke.py --suites=replica_sets_jscore_passthrough --repeat=1 --basePort=43000 jstests/core/list_collections_no_views.js
      

      SERVER-25942 was supposed to allow listCollections with a filter {type: 'collection'} to not fail on views errors.

      The committed JS test, list_collections_no_views.js, adds additional filtering,

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

      , where {type: {$exists: false}} is supposed to only be needed for versions <= v3.2 compatibility, but the listCollections cmd doesn't work without error if just given {type: 'collection'} for the filter.

      I did not explore how far back this behavior goes.

            Assignee:
            [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            Dianna Hohensee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: