listCollections fails on sharded collection after movePrimary is called

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.0.11, 3.2.9, 3.3.11
    • Component/s: Sharding
    • None
    • Sharding
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Repro steps below, not a regression. Checked back to 3.0.x

      (function() {
          'use strict';
          var checkCollectionExists = function(coll) {
              var collArray = coll.getDB().runCommand("listCollections").cursor.firstBatch;
              var colls = collArray.filter(function(spec) { return spec.name === coll.getName(); });
              assert.eq(1, colls.length, tojson(collArray));
          }
      
          var st = new ShardingTest({shards: 2});
          var mongos = st.s;
          var configDb = st.s.getDB("config");
          var shard0 = st.shard0.shardName;
          var shard1 = st.shard1.shardName;
          var coll = mongos.getCollection('test.list_collections');
      
          assert.commandWorked(mongos.adminCommand({ enableSharding: coll.getDB() + ""}));
          assert.commandWorked(
              mongos.adminCommand({ shardCollection: coll + "", key: { "x" : 1 }}));
      
          jsTestLog("insert a single document into mycoll");
          assert.writeOK(coll.insert({ "x" : 1 }));
          checkCollectionExists(coll);
      
          jsTestLog("check that primary shard is " + shard0 + " then moving primary to " + shard1);
          assert.eq(1, configDb.databases.count({ "_id" : coll.getDB().getName(), "primary" : shard0 }));
          assert.commandWorked(mongos.adminCommand({ movePrimary: coll.getDB().getName(), to: shard1}));
          checkCollectionExists(coll);
      
          st.stop();
      })();
      

            Assignee:
            [DO NOT USE] Backlog - Sharding Team
            Reporter:
            Daniel Pasette (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: