The MariaDB FLUSH TABLES command closes only unused tables
Regular session one
Select id,sleep (60) from T1
The T1 table holds a METADATA LOCK (MDL) metadata lock because it is not finished.
Conversation two
FLUSH TABLES
Before MariaDB version 10.4, executing FLUSH TABLES forced all tables to close, because once the session held the MDL metadata lock, the fixed FLUSH TABLES would wait for Waiting for table metadata lock.
In the GA version of MariaDB 10.4, only unused tables will be closed, and tables in use will not be affected. (unless you manually specify a table, such as FLUSH TABLES T1, the T1 table will be forced to close)
Scenario: when MHA online switching calls the master_ip_online_change script, the first step will execute FLUSH NO_WRITE_TO_BINLOG TABLES to close all tables. At this point, if your database has unfinished slow SQL,FLUSH NO_WRITE_TO_BINLOG TABLES, it will get stuck and cannot be switched.
Note: this feature is not supported in MySQL version 8.0.17