From d2a867cdf08850563a39381aee09b4528442feb8 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 23 Oct 2023 20:24:24 +0300 Subject: [PATCH] MDEV-32532 Assertion failure in ddl_log_increment_phase_no_lock upon .. The reason for the bug was that spider plugin does some ALTER TABLE commands before recovery is done, which was not expected. Fixed by resetting the ddl_log lists in create_ddl_log() --- sql/ddl_log.cc | 41 +++++++++++-------- .../mysql-test/spider/bugfix/r/ddl_log.result | 12 ++++++ .../mysql-test/spider/bugfix/t/ddl_log.test | 17 ++++++++ 3 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/ddl_log.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/ddl_log.test diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 5e13a8663dc..30b15a95de1 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -181,6 +181,8 @@ static constexpr unsigned DDL_LOG_BACKUP_OFFSET_POS= 8; /* Sum of the above variables */ static constexpr unsigned DDL_LOG_HEADER_SIZE= 4+2+2+1; +static void ddl_log_free_lists(); + /** Sync the ddl log file. @@ -734,6 +736,7 @@ static bool create_ddl_log() char file_name[FN_REFLEN]; DBUG_ENTER("create_ddl_log"); + ddl_log_free_lists(); global_ddl_log.open= 0; global_ddl_log.created= 1; global_ddl_log.num_entries= 0; @@ -2826,24 +2829,11 @@ int ddl_log_execute_recovery() } -/** - Release all memory allocated to the ddl log and delete the ddl log -*/ - -void ddl_log_release() +static void ddl_log_free_lists() { - char file_name[FN_REFLEN]; - DDL_LOG_MEMORY_ENTRY *free_list; - DDL_LOG_MEMORY_ENTRY *used_list; - DBUG_ENTER("ddl_log_release"); + DDL_LOG_MEMORY_ENTRY *free_list= global_ddl_log.first_free; + DDL_LOG_MEMORY_ENTRY *used_list= global_ddl_log.first_used; - if (!global_ddl_log.initialized) - DBUG_VOID_RETURN; - - global_ddl_log.initialized= 0; - - free_list= global_ddl_log.first_free; - used_list= global_ddl_log.first_used; while (used_list) { DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry; @@ -2856,6 +2846,25 @@ void ddl_log_release() my_free(free_list); free_list= tmp; } + global_ddl_log.first_free= global_ddl_log.first_used= 0; +} + + +/** + Release all memory allocated to the ddl log and delete the ddl log +*/ + +void ddl_log_release() +{ + char file_name[FN_REFLEN]; + DBUG_ENTER("ddl_log_release"); + + if (!global_ddl_log.initialized) + DBUG_VOID_RETURN; + + global_ddl_log.initialized= 0; + ddl_log_free_lists(); + my_free(global_ddl_log.file_entry_buf); global_ddl_log.file_entry_buf= 0; close_ddl_log(); diff --git a/storage/spider/mysql-test/spider/bugfix/r/ddl_log.result b/storage/spider/mysql-test/spider/bugfix/r/ddl_log.result new file mode 100644 index 00000000000..2abbcc6bc30 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/ddl_log.result @@ -0,0 +1,12 @@ +# restart: --plugin-load-add=ha_spider +# +# MDEV-32532 Assertion failure in ddl_log_increment_phase_no_lock upon +# partition operations with spider plugin loaded +# +CREATE TABLE t1 (a INT) PARTITION BY HASH (a) PARTITIONS 2; +ALTER TABLE t1 REBUILD PARTITION p0; +drop table t1; +# +# End of 10.10 +# +uninstall plugin spider; diff --git a/storage/spider/mysql-test/spider/bugfix/t/ddl_log.test b/storage/spider/mysql-test/spider/bugfix/t/ddl_log.test new file mode 100644 index 00000000000..4fe45b83dea --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/ddl_log.test @@ -0,0 +1,17 @@ +--source include/have_partition.inc +--let $restart_parameters= --plugin-load-add=ha_spider +--source include/restart_mysqld.inc + +--echo # +--echo # MDEV-32532 Assertion failure in ddl_log_increment_phase_no_lock upon +--echo # partition operations with spider plugin loaded +--echo # +CREATE TABLE t1 (a INT) PARTITION BY HASH (a) PARTITIONS 2; +ALTER TABLE t1 REBUILD PARTITION p0; +drop table t1; + +--echo # +--echo # End of 10.10 +--echo # + +uninstall plugin spider;