Bug #113535 Drop table in background list will remain file exists in directory
Submitted: 2 Jan 2024 9:58 Modified: 8 Jan 2024 13:28
Reporter: Fanfan Zhang Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0.35 OS:Any
Assigned to: CPU Architecture:Any

[2 Jan 2024 9:58] Fanfan Zhang
Description:
After code review, I have found it the drop table may left the ibd file remaining in data directory and it will block next create same table name. 

Here are the process:
1. user thread executes "drop table t1", the function row_drop_table_for_mysql checks table->n_foreign_key_checks_running > 0 or table->get_ref_count() > 0, the table will insert into background list. 
2. The master thread will loop background list and do row_drop_table_for_mysql again, let's suppose the function succeed this time, which will write DDL Log (log_ddl->write_delete_space_log).
3. The master thread does't execute post_ddl, which will actually clear the ibd file. So the ibd still exists in the data directory. It will cause the next create same table error. 

My Question is:
1. row_add_table_to_background_drop_list doesn't add table name to row_drop_list for debug mode, which makes no mtr case for this situation.
2. The master thread doesn't do post_ddl, the remaining ibd file will be a problem.

How to repeat:
row_add_table_to_background_drop_list doesn't add table name to row_drop_list for debug mode, which makes no mtr case for this situation.
[8 Jan 2024 13:31] MySQL Verification Team
Hi Mr. Zhang,

Thank you for your bug report.

However, we were not able to repeat it.

We ran concurrently, in the same time, "drop table t1" and in each run one of the threads returned success, while other  threads returned the error that table `t1` does not exist.

We used `mysqlslap` which runs every command simultaneously in the number of threads. We used 10 (ten) threads. We also tried with 3, 5 and 20 threads and always got a correct behaviour.

Can you provide us with a test case that will prove otherwise ?????

Many thanks in advance.