[SERVER-54377] listDatabases doesn't include sharded databases without collections Created: 08/Feb/21  Updated: 06/Dec/22  Resolved: 12/Nov/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 4.0.22, 4.4.3, 4.2.12, 4.9.0-alpha4
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Tommaso Tocci Assignee: [DO NOT USE] Backlog - Sharding EMEA
Resolution: Won't Do Votes: 0
Labels: sharding-wfbf-sprint
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File list_datatabases.patch    
Issue Links:
Related
related to SERVER-61452 Complete TODO listed in SERVER-54377 Closed
Assigned Teams:
Sharding EMEA
Operating System: ALL
Steps To Reproduce:

Apply the following patch and run jstests/sharding/listDatabases.js

list_datatabases.patch

Participants:

 Description   

The listDatabases command doesn't reports databases that have been created through the enableSharding command that do not contains any collections yet.



 Comments   
Comment by Kaloian Manassiev [ 10/Feb/21 ]

Our official docs are written from a user's point of view. Therefore, a database entry, which is in config.databases but without any collections on it doesn't mean anything. I guess the only meaningful use case is to "remind me" that I need to drop some database I am not using.

Comment by Tommaso Tocci [ 09/Feb/21 ]

Quoting our official docs:
> The listDatabases command provides a list of all existing databases along with basic statistics about them.

It doesn't mention any exception regarding empty databases. So yes, even if it is not so important I still think this is a bug.

Comment by Kaloian Manassiev [ 09/Feb/21 ]

tommaso.tocci, given Louis' explanation above, do you think this is still a bug? I think it likely doesn't matter from user point of view whether listDatabases returns them or not.

Comment by Louis Williams [ 08/Feb/21 ]

kaloian.manassiev, that is correct. A database only exists if there are collections that are prefixed with that database name. It would add significant complexity for questionable benefit by having additional database metadata that is separate from collections.

Comment by Kaloian Manassiev [ 08/Feb/21 ]

I believe this is a side effect of the fact that MongoD doesn't have the concept of creating a database. There is no createDatabase command for example and the only way one can end up with a database that doesn't have any collections is to actually create a db.collection and then drop the collection. But probably even in that case, some system collections will remain under that db.

louis.williams, in the MongoD catalog is it possible to have just a database without any collections?

Generated at Thu Feb 08 05:33:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.