-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Storage
-
None
-
Fully Compatible
-
v4.2
-
Execution Team 2019-08-12, Execution Team 2019-08-26, Execution Team 2019-09-09, Execution Team 2019-09-23, Execution Team 2019-10-07, Execution Team 2019-10-21
-
(copied to CRM)
-
0
We can demote the lock needed for DatabaseHolder::close() from an exclusive global lock to a database exclusive lock as the DatabaseHolder is protected by a mutex. With this, we can also remove the exclusive global locks needed in the dropDatabase command.
Old Description:
Currently, the kv engine does not check to see if a database is empty after a collection drop. Thus, empty databases can persist until mongod restarts (or the catalog is reloaded via replication rollback to stable timestamp). This situation is usually benign, but a database entry's presence does do one thing: it enforces that no other databases that are spelled the same but differ in capitalization can be created.
Because recover-to-timestamp exists, it can result in some replica set nodes having a catalog entry for an empty database while other nodes do not have such an entry. This can result in the ability to crash secondary nodes that have an empty database entry that a primary node does not have - by attempting to create a database with a different case than the existing empty database entry.
To fix this, we can check to see if a database is empty (i.e., no collection entries remain in the catalog) after a collection drop. If it is indeed empty, we can attempt to close the database by locking it in X mode and calling DatabaseHolder::close().
- depends on
-
SERVER-34431 Move DatabaseShardingState into its own map to correctly handle database versioning in face of drop/recreate
- Closed
-
SERVER-43890 Remove two-phase database drops
- Closed
- is depended on by
-
SERVER-37552 Illegal concurrent access to KVDatabaseCatalogEntryBase::_collections
- Closed
-
SERVER-35283 KVStorageEngine::listDatabases() omits databases that exist but have no collections
- Closed
-
SERVER-42053 proactively drop newly empty databases (sharding)
- Closed
- related to
-
SERVER-42053 proactively drop newly empty databases (sharding)
- Closed
- split from
-
SERVER-43242 Deadlock involving commands acquiring global X lock and prepared transactions waiting for write concern
- Closed
- split to
-
SERVER-43925 Proactively close newly empty databases
- Needs Scheduling