[SERVER-43925] Proactively close newly empty databases Created: 09/Oct/19 Updated: 07/Feb/24 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Gregory Wlodarek | Assignee: | Backlog - Storage Execution Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Assigned Teams: |
Storage Execution
|
||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Linked BF Score: | 0 | ||||||||||||||||||||||||||||
| 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. 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(). |
| Comments |
| Comment by Gregory Wlodarek [ 09/Oct/19 ] |
|
After discussing with the team, we're going to set this ticket aside as there's no urgency for it right now and needs more work to be done before tackling it.
This is problematic to do today because if we remove the Database in the DatabaseHolder when the last collection is dropped, then we lose our isDropPending flag (a member of the Database object class). This flag prevents new collections from being created on the database while waiting for the second phase of collection drops to be majority committed when using majority read concern. Timeline of events if we implicitly close empty databases today Client 1:
Client 2:
Client 1:
Another issue that would occur is during rollback. When the last collection is first phase dropped and rollback occurs, the Database object will no longer exist in the DatabaseHolder. |