[SERVER-25774] listCollections fails on sharded collection after movePrimary is called Created: 24/Aug/16  Updated: 06/Dec/22  Resolved: 02/Dec/19

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.0.11, 3.2.9, 3.3.11
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding
Operating System: ALL
Participants:

 Description   

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();
})();



 Comments   
Comment by Esha Maharishi (Inactive) [ 02/Dec/19 ]

Fixed by PM-1051.

Generated at Thu Feb 08 04:10:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.