Can't Move Shard, Invalid DB Name

66 views
Skip to first unread message

tmountain

unread,
Nov 14, 2011, 2:20:27 PM11/14/11
to mongodb-user
We're trying to finish draining a shard, and we can't complete the
process because a database with an invalid name is primary to the
shard we're trying to remove. I'm not certain how the database got
created, but it was likely a typo when setting up sharding.

> db.printShardingStatus()
... abbreviated output ...

{ "_id" : "notifications", "partitioned" : true, "primary" :
"feeds_fio_1" }
notifications.userNotifications chunks:
feeds_fio_1 1
{ "sk" : { $minKey : 1 } } -->> { "sk" : { $maxKey : 1 } } on :
feeds_fio_1 { "t" : 2000, "i" : 0 }
{ "_id" : "notifications ", "partitioned" : false, "primary" :
"feeds_fio_3" }

The first "notifications" db is the db that's actually in production.
The second db has a space at the end (i.e., "notifications "). It
seems that neither the PHP, Python, or Ruby driver can deal with this
DB correctly, and trying to manipulate it from the mongo shell fails
as well.

I'm tempted to just try doing this: db.databases.remove({'_id':
'notifications '}); but I'm afraid it might have some unwanted side-
effect like removing the notifications db that's in production
(developer paranoia here).

We've tried moving it to another primary, but again this fails (due to
the space in the name).

> db.runCommand({moveprimary:"notifications ", to:"feeds_fio_1"});
{ "ok" : 0, "errmsg" : "clone failed" }

Please advise how to proceed here.

Richard Kreuter

unread,
Nov 15, 2011, 10:20:16 AM11/15/11
to mongodb-user
Are there any databases named "notifications " in the feeds_fio_3
shard? There shouldn't be. If there aren't, you can safely remove
the spurious entry in the config database's databases collection,
e.g.,

db=db.getSiblingDB("config")
db.databases.remove({ _id : "notifications " });

(In case you're interested, I've created a JIRA issue about the
creation of entries in config.databases with invalid dbnames:

https://jira.mongodb.org/browse/SERVER-4284

)

Regards,
Richard

Richard Kreuter

unread,
Nov 15, 2011, 10:32:23 AM11/15/11
to mongodb-user
Sorry, the first sentence ought to have read:

'Are there any databases named "notifications " in any of your
shards?'

tmountain

unread,
Nov 15, 2011, 12:00:40 PM11/15/11
to mongodb-user
Ok, thanks for the reply. Do I need to do this on each config server?

Marc

unread,
Nov 15, 2011, 12:12:35 PM11/15/11
to mongodb-user
No. Just once through the mongos.

tmountain

unread,
Nov 15, 2011, 3:03:51 PM11/15/11
to mongodb-user
Worked beautifully. Thanks guys.
Reply all
Reply to author
Forward
0 new messages