[SERVER-6057] can't remove ill formed database Created: 11/Jun/12  Updated: 15/Aug/12  Resolved: 18/Jun/12

Status: Closed
Project: Core Server
Component/s: Admin, Shell
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Grégoire Seux Assignee: Matt Dannenberg
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-4584 mongod crashes when trying to create ... Closed
Operating System: ALL
Participants:

 Description   

if you create ill-named database (such as "admin sha" or "*") you can't rmeove them.

How to do it :
use admin sha
db.dropDatabase()

you get :
"errmsg" : "

{ assertion: \"invalid db name: admin sha\", assertionCode: 13280, errmsg: \"db assertion failure\", ok: 0.0 }

"

if you try to remove it with a command :
db.runCommand(

{dropDatabase : "admin sha"}

)

{ "ok" : 0, "errmsg" : "invalid params" }

Creating such ill-named database should be forbidden (spaces in the name) but it should be possible to remove them.



 Comments   
Comment by Grégoire Seux [ 18/Jun/12 ]

ok, thanks
of course, since this is a production environment, this is not easy to shutdown a whole shard at a time

Comment by Matt Dannenberg [ 15/Jun/12 ]

Yes I took the following steps and it should work for you as well.

I shut down the shards one at a time, removed the files from the data directory, and started the shards back up. Once I had done this to each shard, I connected to mongos and removed the entry for this database from the config.collections collection.

Comment by Grégoire Seux [ 15/Jun/12 ]

Ok thanks.
This is difficult to do this in a replicated and shardedenvironment, but I guess I can shutdown, remove files and restart servers one at a time.
The only thing then is to remove the entry from the config db (which lies on 3 instances), can I make it from the mongoS ?

Comment by Matt Dannenberg [ 13/Jun/12 ]

The workaround for dropping such a database would be to delete the db files and ns file (while the server is shutdown of course).

Comment by Grégoire Seux [ 13/Jun/12 ]

first I typed :
use admin test

then I typed :
db.printShardingStatus()
and I have seen the database called 'admin test' appear

Comment by Matt Dannenberg [ 12/Jun/12 ]

I am not sure if I followed what you posted earlier. Can you please post the exact commands that you used to create an ill formed db?

Comment by Grégoire Seux [ 12/Jun/12 ]

quite easily :
use admin test

then type :
db.printShardingStatus() and you will see it appear.
However show dbs does not reveal it.

Comment by Daniel Pasette (Inactive) [ 11/Jun/12 ]

How did you create the 'admin sha' db? I tried a few tricks in the shell and via python, but couldn't easily make it happen in order to repro.

Comment by Grégoire Seux [ 11/Jun/12 ]

It works for * but not for spaces :

db.getSiblingDB("admin sha").dropDatabase()
{
"ok" : 0,
"errmsg" : "

{ assertion: \"invalid db name: admin sha\", assertionCode: 13280, errmsg: \"db assertion failure\", ok: 0.0 }

"
}

Comment by Ian Whalen (Inactive) [ 11/Jun/12 ]

Fix to check for spaces and illegal characters (/\. "*<>:|?) made in v2.1.0

In order to drop a database you can run:

db.getSiblingDB("*").dropDatabase()

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