Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Won't Fix
-
None
-
None
-
None
-
v4.0, v3.6
-
Storage NYC 2018-12-31
-
(copied to CRM)
Description
KVStorageEngine::listDatabases() will skip databases that don't have any collections:
kv_storage_engine.cpp |
|
370
|
void KVStorageEngine::listDatabases(std::vector<std::string>* out) const { |
371
|
stdx::lock_guard<stdx::mutex> lk(_dbsLock);
|
372
|
for (DBMap::const_iterator it = _dbs.begin(); it != _dbs.end(); ++it) { |
373
|
if (it->second->isEmpty()) |
374
|
continue; |
375
|
out->push_back(it->first);
|
376
|
}
|
377
|
}
|
I'm unsure of why this is, but there is a legitimate use case for listing empty databases. Consider the following sequence of user operations – the user is misled into thinking the database "bloop" doesn't exist because it is totally omitted from the listDatabases output even though the database does, in fact, exist:
> use bloop
|
switched to db bloop
|
> db.coll.insert({x: 1});
|
WriteResult({ "nInserted" : 1 })
|
> show dbs
|
admin 0.000GB
|
bloop 0.000GB
|
config 0.000GB
|
local 0.000GB
|
> assert(db.coll.drop());
|
true
|
> show dbs
|
admin 0.000GB
|
config 0.000GB
|
local 0.000GB
|
> use BLOOP
|
switched to db BLOOP
|
> db.coll.insert({x: 1})
|
WriteResult({
|
"nInserted" : 0,
|
"writeError" : {
|
"code" : 13297,
|
"errmsg" : "db already exists with different case already have: [bloop] trying to create [BLOOP]"
|
}
|
})
|
Attachments
Issue Links
- depends on
-
SERVER-33272 The DatabaseHolder::close() function no longer requires a global write lock and neither does the dropDatabase command.
-
- Closed
-