From 92ff7bb63fee54a932ca0b7d8092af5aac1ded57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 15 Dec 2022 12:45:26 +0200 Subject: MDEV-30227 [ERROR] [FATAL] InnoDB: fdatasync() returned 9 fil_space_t::flush(): If the CLOSING flag is set, the file may already have been closed, resulting in EBADF being returned by fdatasync(). In any case, the thread that had set the flag should take care of invoking os_file_flush_func(). The crash occurred during the execution of FLUSH TABLES...FOR EXPORT. Tested by: Matthias Leich --- storage/innobase/include/fil0fil.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index bcbcb02ccdb..af941e359f8 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1469,9 +1469,10 @@ template inline void fil_space_t::flush() } else if (have_reference) flush_low(); - else if (!(acquire_low() & STOPPING)) + else { - flush_low(); + if (!(acquire_low() & (STOPPING | CLOSING))) + flush_low(); release(); } } -- cgit v1.2.1 From 0a67daad060459c27a1fb776e0a654a76c457804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 15 Dec 2022 16:18:43 +0200 Subject: MDEV-30235 InnoDB crash on table-rebuilding DDL when the statistics tables are corrupted commit_try_rebuild(): Only invoke trx_t::drop_table_statistics() if both InnoDB statistics tables are accessible (and exclusively locked by the current transaction). This avoids a crash due to ut_a(sym_node->table != NULL) in pars_retrieve_table_def(). The crash was repeated on a partial copy of a MariaDB 10.3 data directory that lacked the *.ibd files for the statistics tables. --- storage/innobase/handler/handler0alter.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'storage') diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index f91c0a23c08..dd83ed49af0 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10101,6 +10101,7 @@ commit_try_rebuild( ha_innobase_inplace_ctx*ctx, TABLE* altered_table, const TABLE* old_table, + bool statistics_exist, trx_t* trx, const char* table_name) { @@ -10171,7 +10172,9 @@ commit_try_rebuild( if (error == DB_SUCCESS) { /* The statistics for the surviving indexes will be re-inserted in alter_stats_rebuild(). */ - error = trx->drop_table_statistics(old_name); + if (statistics_exist) { + error = trx->drop_table_statistics(old_name); + } if (error == DB_SUCCESS) { error = trx->drop_table(*user_table); } @@ -11316,6 +11319,7 @@ fail: if (commit_try_rebuild(ha_alter_info, ctx, altered_table, table, + table_stats && index_stats, trx, table_share->table_name.str)) { goto fail; -- cgit v1.2.1