Bug #98083 Restarting the computer when deleting the database will cause directory residues
Submitted: 27 Dec 2019 9:02 Modified: 14 Mar 2023 9:14
Reporter: jinming liao Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.16, 8.0.32 OS:Any
Assigned to: CPU Architecture:Any

[27 Dec 2019 9:02] jinming liao
Description:
When deleting the database, restart the computer, then pull up the database again, and create a database with the same name, the following error will be reported:

ERROR 3678 (HY000): Schema directory './test_db' already exists. This must be resolved manually (e.g. by moving the schema directory to another location).

How to repeat:
Write a shell script, continuously create and delete a database with the same name, and restart the computer. However, this approach may not necessarily occur, the method must be:

Modify sql_db.cc:mysql_rm_db

if (! error && schema_dirp! = nullptr) {
       Rmdir_error_handler rmdir_handler;
       thd-> push_internal_handler (& rmdir_handler);
       abort (); // add abort
       (void) rm_dir_w_symlink (path, true);
       thd-> pop_internal_handler ();
}

When the database hangs, pull up the database again, create a database with the same name, and then report the following error:

ERROR 3678 (HY000): Schema directory './test_db' already exists. This must be resolved manually (e.g. by moving the schema directory to another location).
[14 Jan 2020 14:23] MySQL Verification Team
Hi Mr. Liao,

Thank you for your bug report.

However, this is not a bug.

MySQL 8.0 has introduced complete mechanism for the management of the schema and tables. This system does not allow for the manual creation or deletion of tables or databases.

This is all described in our 8.0 Reference Manual.

Not a bug.
[14 Mar 2023 6:42] Marcin Babij
Hell Jinming,
Indeed this operation is not crash-safe. DDLs are atomic and crash-safe for InnoDB tables, but a schema is not an InnoDB object and the MySQL Server does not seem to have provision for supporting it.
It should be improved. That is, the DROP DATABASE should be atomic and crash-safe, and this report is a legitimate issue. I'm re-opening the bug report.
Thanks for the bug report.
[14 Mar 2023 9:14] MySQL Verification Team
Hello jinming liao,

I'm able to reproduce this with 8.0.32.
Verifying for now as Marcin concluded it as a valid request.

regards,
Umesh