From b88f1267e45123db83059d28171c35863b05abb7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 19 Sep 2024 18:57:37 +0200 Subject: [PATCH] MDEV-33373 part 2: Unexpected ER_FILE_NOT_FOUND upon reading from logging table after crash recovery CSV engine shoud set my_errno if use it. --- mysql-test/main/log_crash.result | 17 +++++++++++++++++ mysql-test/main/log_crash.test | 25 +++++++++++++++++++++++++ storage/csv/ha_tina.cc | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/log_crash.result create mode 100644 mysql-test/main/log_crash.test diff --git a/mysql-test/main/log_crash.result b/mysql-test/main/log_crash.result new file mode 100644 index 00000000000..5a820a1fd01 --- /dev/null +++ b/mysql-test/main/log_crash.result @@ -0,0 +1,17 @@ +# +# MDEV-33373: Unexpected ER_FILE_NOT_FOUND upon reading from logging +# table after crash recovery +# +call mtr.add_suppression("Table 'general_log' is marked as crashed and should be repaired"); +SET GLOBAL log_output="TABLE"; +CREATE TABLE t (a INT); +# restart +DROP TABLE t; +SELECT count(*) FROM mysql.general_log; +count(*) +5 +Warnings: +Error 1194 Table 'general_log' is marked as crashed and should be repaired +# +# End of 10.5 tests +# diff --git a/mysql-test/main/log_crash.test b/mysql-test/main/log_crash.test new file mode 100644 index 00000000000..3a6a2ff4454 --- /dev/null +++ b/mysql-test/main/log_crash.test @@ -0,0 +1,25 @@ + +--source include/not_embedded.inc +--source include/have_csv.inc + +--echo # +--echo # MDEV-33373: Unexpected ER_FILE_NOT_FOUND upon reading from logging +--echo # table after crash recovery +--echo # + +call mtr.add_suppression("Table 'general_log' is marked as crashed and should be repaired"); + +--disable_ps_protocol +SET GLOBAL log_output="TABLE"; +CREATE TABLE t (a INT); +--disable_ps_protocol +--let $shutdown_timeout= 0 +--source include/restart_mysqld.inc +DROP TABLE t; +--disable_ps_protocol +SELECT count(*) FROM mysql.general_log; +--enable_ps_protocol + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 04e63530c0e..894fdf2f200 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -333,7 +333,7 @@ static int read_meta_file(File meta_file, ha_rows *rows) /* check crashed bit and magic number */ if ((meta_buffer[0] != (uchar)TINA_CHECK_HEADER) || ((bool)(*ptr)== TRUE)) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + DBUG_RETURN(my_errno= HA_ERR_CRASHED_ON_USAGE); mysql_file_sync(meta_file, MYF(MY_WME)); @@ -974,7 +974,7 @@ int ha_tina::open(const char *name, int mode, uint open_options) if (share->crashed && !(open_options & HA_OPEN_FOR_REPAIR)) { free_share(share); - DBUG_RETURN(my_errno ? my_errno : HA_ERR_CRASHED_ON_USAGE); + DBUG_RETURN(my_errno); } local_data_file_version= share->data_file_version;