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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Storage
    • None
    • Storage Execution
    • ALL

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-execution Backlog - Storage Execution Team
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: