summaryrefslogtreecommitdiff
path: root/sql/sql_partition_admin.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-10-15 02:25:57 +0300
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:54:12 +0200
commit47010ccffa8db1b88883314932e1a0f33ec32bc0 (patch)
tree4536c39f1bc71c82cf78ed2804caa3b2e348e222 /sql/sql_partition_admin.cc
parent55c771b4f3e1c8a42f018730f39a26278abcf817 (diff)
downloadmariadb-git-47010ccffa8db1b88883314932e1a0f33ec32bc0.tar.gz
MDEV-23842 Atomic RENAME TABLE
- Major rewrite of ddl_log.cc and ddl_log.h - ddl_log.cc described in the beginning how the recovery works. - ddl_log.log has unique signature and is dynamic. It's easy to add more information to the header and other ddl blocks while still being able to execute old ddl entries. - IO_SIZE for ddl blocks is now dynamic. Can be changed without affecting recovery of old logs. - Code is more modular and is now usable outside of partition handling. - Renamed log file to dll_recovery.log and added option --log-ddl-recovery to allow one to specify the path & filename. - Added ddl_log_entry_phase[], number of phases for each DDL action, which allowed me to greatly simply set_global_from_ddl_log_entry() - Changed how strings are stored in log entries, which allows us to store much more information in a log entry. - ddl log is now always created at start and deleted on normal shutdown. This simplices things notable. - Added probes debug_crash_here() and debug_simulate_error() to simply crash testing and allow crash after a given number of times a probe is executed. See comments in debug_sync.cc and rename_table.test for how this can be used. - Reverting failed table and view renames is done trough the ddl log. This ensures that the ddl log is tested also outside of recovery. - Added helper function 'handler::needs_lower_case_filenames()' - Extend binary log with Q_XID events. ddl log handling is using this to check if a ddl log entry was logged to the binary log (if yes, it will be deleted from the log during ddl_log_close_binlogged_events() - If a DDL entry fails 3 time, disable it. This is to ensure that if we have a crash in ddl recovery code the server will not get stuck in a forever crash-restart-crash loop. mysqltest.cc changes: - --die will now replace $variables with their values - $error will contain the error of the last failed statement storage engine changes: - maria_rename() was changed to be more robust against crashes during rename.
Diffstat (limited to 'sql/sql_partition_admin.cc')
-rw-r--r--sql/sql_partition_admin.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 18c53a7e2fb..ca564af1bf6 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -355,13 +355,14 @@ static bool exchange_name_with_ddl_log(THD *thd,
DBUG_RETURN(TRUE);
/* prepare the action entry */
+ bzero(&exchange_entry, sizeof(exchange_entry));
exchange_entry.entry_type= DDL_LOG_ENTRY_CODE;
exchange_entry.action_type= DDL_LOG_EXCHANGE_ACTION;
- exchange_entry.next_entry= 0;
- exchange_entry.name= name;
- exchange_entry.from_name= from_name;
- exchange_entry.tmp_name= tmp_name;
- exchange_entry.handler_name= ha_resolve_storage_engine_name(ht);
+ lex_string_set(&exchange_entry.name, name);
+ lex_string_set(&exchange_entry.from_name, from_name);
+ lex_string_set(&exchange_entry.tmp_name, tmp_name);
+ lex_string_set(&exchange_entry.handler_name,
+ ha_resolve_storage_engine_name(ht));
exchange_entry.phase= EXCH_PHASE_NAME_TO_TEMP;
mysql_mutex_lock(&LOCK_gdl);
@@ -377,8 +378,8 @@ static bool exchange_name_with_ddl_log(THD *thd,
DBUG_EXECUTE_IF("exchange_partition_fail_2", goto err_no_execute_written;);
DBUG_EXECUTE_IF("exchange_partition_abort_2", DBUG_SUICIDE(););
- if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, FALSE,
- &exec_log_entry)))
+ if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos,
+ &exec_log_entry)))
goto err_no_execute_written;
/* ddl_log is written and synced */
@@ -457,7 +458,7 @@ err_rename:
(void) ddl_log_execute_entry(current_thd, log_entry->entry_pos);
mysql_mutex_lock(&LOCK_gdl);
/* mark the execute log entry done */
- (void) ddl_log_write_execute_entry(0, TRUE, &exec_log_entry);
+ (void) ddl_log_disable_execute_entry(&exec_log_entry);
/* release the execute log entry */
(void) ddl_log_release_memory_entry(exec_log_entry);
err_no_execute_written: