Description:
When a table cannot be opened, the server returns the error in its Comment in SHOW TABLE STATUS, which is expected. But the same error is returned for every following table of the result too, replacing their real comments. Tables listed before the unreadable one are correct and all the statistics are correct, only the comments are wrong.
The first SHOW TABLE STATUS after the table becomes unreadable is still correct, only every later execution is wrong. It stays wrong after a restart.
The cached statistics seem to be the cause: with information_schema_stats_expiry=0 the result is correct. Selecting TABLE_COMMENT alone is correct as well, adding a statistics column such as DATA_LENGTH returns the error for all the following tables again.
This is not specific to ARCHIVE, a MyISAM table with a deleted .MYD behaves the same.
Possibly related to Bug #94468 (fixed in 8.0.17) which also returned a wrong message in TABLE_COMMENT and was also correct only in the first query.
How to repeat:
CREATE DATABASE min1;
USE min1;
CREATE TABLE t1_broken (id int) ENGINE=ARCHIVE COMMENT='c1';
CREATE TABLE t2_ok (id int) ENGINE=InnoDB COMMENT='c2';
FLUSH TABLES;
Delete t1_broken.ARZ from the min1 directory in the data directory, then run SHOW TABLE STATUS twice. The first execution is still correct:
t1_broken | Can't find file: 't1_broken' (errno: 2 - No such file or directory)
t2_ok | c2
The second and every further execution:
t1_broken | Can't find file: 't1_broken' (errno: 2 - No such file or directory)
t2_ok | Can't find file: 't1_broken' (errno: 2 - No such file or directory)
Expected: t2_ok keeps its own comment c2 also in the second execution.
Suggested fix:
Do not use a remembered error for a table whose own statistics were read successfully.