how to clear out garbage tables from broken mongodb shard

702 views Asked by At

I am trying to remove the remains of some data from a shard that proved to be too slow to be useful. Some programming error produced a bunch of databases which have bogus names:

mongos> db.runCommand( { removeShard: "shard0002" }); 
{
    "msg" : "draining ongoing",
    "state" : "ongoing",
    "remaining" : {
            "chunks" : NumberLong(0),
            "dbs" : NumberLong(30)
    },
    "note" : "you need to drop or movePrimary these databases",
    "dbsToMove" : [
            "*�\u000f",
            "M�\u0006",
            "ed_tione_tr�\u0002",
            "sns�\u0002",
            "sns�\u0002",
            "sns�\u0002",
            "sns�\u0002",
            "sns�\u0002",
            "sns�\u0002",
            "sn�\u0002",
            "sn�\u0002",
            "sn�\u0002",
            "sn�\u0002",
            "sn�\u0002",
            "sn�\u0002",
            "sn�\u0002",
            "s�\u0002",
            "s�\u0002",
            "�\u0002",
            "�\u0003",
            "�\u0006",
            "�%\u0003",
            "��\r",
            "�\u0007",
            "�\u0002",
            "�\u0002",
            "�\u0002",
            "�\u0002",
            "�\u0002",
            "�\f"
    ],
    "ok" : 1
}

I access the names, which I can't really type:

mongos> var k = db.runCommand( { removeShard: "shard0002" });
mongos> var n = k.dbsToMove

but, even this doesn't help me:

mongos> db.adminCommand({ movePrimary: n[10],to : "shard0001" });
{ "ok" : 0, "errmsg" : "can't find db!" }

I'm running mongodb 2.6.7, and getting rid of this useless shard is one thing keeping from easily upgrading.

1

There are 1 answers

0
mcr On

In the end, I did this:

use config
db.shards.remove({"_id":"shard0002"});

as all the data I cared about had already been drained. Now I have two more shards to drain, and they also have garbage databases, fortunately not ones that were untypeable.

I'd still like a better answer on how to remove these garbage databases.