cleanup: reduce error injection noise in partitioning

This commit is contained in:
Sergei Golubchik 2021-09-12 19:06:18 +02:00
parent b7bba721ee
commit 428024524c
6 changed files with 250 additions and 96 deletions

View file

@ -0,0 +1,197 @@
--- alter_partition.result
+++ alter_partition,innodb.reject
@@ -12,12 +12,9 @@
end $
# QUERY: ALTER TABLE t1 CONVERT PARTITION p1 TO TABLE tp1
# CRASH: crash_create_before_create_frm
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -33,12 +30,9 @@
12
22
# CRASH: crash_alter_partition_after_create_frm
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -54,12 +48,9 @@
12
22
# CRASH: crash_alter_partition_after_write_frm
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -75,12 +66,9 @@
12
22
# CRASH: crash_convert_partition_1
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -96,12 +84,9 @@
12
22
# CRASH: crash_convert_partition_2
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -117,12 +102,9 @@
12
22
# CRASH: crash_convert_partition_3
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -138,12 +120,9 @@
12
22
# CRASH: crash_convert_partition_4
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -159,12 +138,9 @@
12
22
# CRASH: crash_convert_partition_5
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -180,12 +156,9 @@
12
22
# CRASH: crash_convert_partition_6
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -201,12 +174,9 @@
12
22
# CRASH: crash_convert_partition_7
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -222,12 +192,9 @@
12
22
# CRASH: crash_convert_partition_8
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#p1.MYD
-t1#P#p1.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#pn.ibd
t1.frm
t1.par
Table Create Table
@@ -243,15 +210,12 @@
12
22
# CRASH: crash_convert_partition_9
-t1#P#p0.MYD
-t1#P#p0.MYI
-t1#P#pn.MYD
-t1#P#pn.MYI
+t1#P#p0.ibd
+t1#P#pn.ibd
t1.frm
t1.par
-tp1.MYD
-tp1.MYI
tp1.frm
+tp1.ibd
master-bin.000001 # Query # # use `test`; ALTER TABLE t1 CONVERT PARTITION p1 TO TABLE tp1
Table Create Table
t1 CREATE TABLE `t1` (

View file

@ -11,7 +11,7 @@ insert into t1 values (2), (12), (22);
flush tables;
end $
# QUERY: ALTER TABLE t1 CONVERT PARTITION p1 TO TABLE tp1
# CRASH: ddl_log_create_before_create_frm
# CRASH: crash_create_before_create_frm
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
@ -32,7 +32,7 @@ x
2
12
22
# CRASH: ddl_log_alter_partition_after_create_frm
# CRASH: crash_alter_partition_after_create_frm
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
@ -53,7 +53,7 @@ x
2
12
22
# CRASH: ddl_log_alter_partition_after_write_frm
# CRASH: crash_alter_partition_after_write_frm
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD

View file

@ -37,9 +37,9 @@ if ($MTR_COMBINATION_ROW)
let $MYSQLD_DATADIR= `SELECT @@datadir`;
let $crash_count= 12;
let $crash_points='ddl_log_create_before_create_frm',
'ddl_log_alter_partition_after_create_frm',
'ddl_log_alter_partition_after_write_frm',
let $crash_points='crash_create_before_create_frm',
'crash_alter_partition_after_create_frm',
'crash_alter_partition_after_write_frm',
'crash_convert_partition_1',
'crash_convert_partition_2',
'crash_convert_partition_3',
@ -104,7 +104,7 @@ while ($r < $statement_count)
RESET MASTER;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--disable_reconnect
--eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1
--eval set @@debug_dbug="+d,$crash"
let $errno=0;
--error 0,2013
--eval $statement;

View file

@ -7382,38 +7382,29 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
to test if recovery is properly done.
*/
if (write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_1") ||
ERROR_INJECT_ERROR("fail_drop_partition_1") ||
ERROR_INJECT("drop_partition_1") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
ERROR_INJECT_CRASH("crash_drop_partition_2") ||
ERROR_INJECT_ERROR("fail_drop_partition_2") ||
ERROR_INJECT("drop_partition_2") ||
wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) ||
ERROR_INJECT_CRASH("crash_drop_partition_3") ||
ERROR_INJECT_ERROR("fail_drop_partition_3") ||
ERROR_INJECT("drop_partition_3") ||
write_log_drop_partition(lpt) ||
(action_completed= TRUE, FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_4") ||
ERROR_INJECT_ERROR("fail_drop_partition_4") ||
ERROR_INJECT("drop_partition_4") ||
alter_close_table(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_5") ||
ERROR_INJECT_ERROR("fail_drop_partition_5") ||
ERROR_INJECT_CRASH("crash_drop_partition_6") ||
ERROR_INJECT_ERROR("fail_drop_partition_6") ||
ERROR_INJECT("drop_partition_5") ||
ERROR_INJECT("drop_partition_6") ||
(frm_install= TRUE, FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
log_partition_alter_to_ddl_log(lpt) ||
(frm_install= FALSE, FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_7") ||
ERROR_INJECT_ERROR("fail_drop_partition_7") ||
ERROR_INJECT("drop_partition_7") ||
mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_8") ||
ERROR_INJECT_ERROR("fail_drop_partition_8") ||
ERROR_INJECT("drop_partition_8") ||
(write_log_completed(lpt, FALSE), FALSE) ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
ERROR_INJECT_ERROR("fail_drop_partition_9"))
ERROR_INJECT("drop_partition_9"))
{
handle_alter_part_error(lpt, action_completed, TRUE, frm_install);
goto err;
@ -7424,32 +7415,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
else if (alter_info->partition_flags & ALTER_PARTITION_CONVERT_OUT)
{
if (mysql_write_frm(lpt, WFRM_WRITE_CONVERTED_TO) ||
ERROR_INJECT_CRASH("crash_convert_partition_1") ||
ERROR_INJECT_ERROR("fail_convert_partition_1") ||
ERROR_INJECT("convert_partition_1") ||
write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_convert_partition_2") ||
ERROR_INJECT_ERROR("fail_convert_partition_2") ||
ERROR_INJECT("convert_partition_2") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
ERROR_INJECT_CRASH("crash_convert_partition_3") ||
ERROR_INJECT_ERROR("fail_convert_partition_3") ||
ERROR_INJECT("convert_partition_3") ||
wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) ||
ERROR_INJECT_CRASH("crash_convert_partition_4") ||
ERROR_INJECT_ERROR("fail_convert_partition_4") ||
ERROR_INJECT("convert_partition_4") ||
write_log_convert_out_partition(lpt) ||
ERROR_INJECT_CRASH("crash_convert_partition_5") ||
ERROR_INJECT_ERROR("fail_convert_partition_5") ||
ERROR_INJECT("convert_partition_5") ||
alter_close_table(lpt) ||
ERROR_INJECT_CRASH("crash_convert_partition_6") ||
ERROR_INJECT_ERROR("fail_convert_partition_6") ||
ERROR_INJECT("convert_partition_6") ||
alter_partition_convert_out(lpt) ||
ERROR_INJECT_CRASH("crash_convert_partition_7") ||
ERROR_INJECT_ERROR("fail_convert_partition_7") ||
ERROR_INJECT("convert_partition_7") ||
(frm_install= true, false) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW|WFRM_BACKUP_ORIGINAL) ||
log_partition_alter_to_ddl_log(lpt) ||
(frm_install= false, false) ||
ERROR_INJECT_CRASH("crash_convert_partition_8") ||
ERROR_INJECT_ERROR("fail_convert_partition_8") ||
ERROR_INJECT("convert_partition_8") ||
((!thd->lex->no_write_to_binlog) &&
((thd->binlog_xid= thd->query_id),
ddl_log_update_xid(lpt->part_info, thd->binlog_xid),
@ -7470,8 +7453,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
*/
write_log_drop_shadow_frm(lpt, WFRM_DROP_BACKUP) ||
ERROR_INJECT_CRASH("crash_convert_partition_9") ||
ERROR_INJECT_ERROR("fail_convert_partition_9"))
ERROR_INJECT("convert_partition_9"))
{
(void) ddl_log_revert(thd, lpt->part_info);
handle_alter_part_error(lpt, true, true, frm_install);
@ -7517,41 +7499,31 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
12)Complete query
*/
if (write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_1") ||
ERROR_INJECT_ERROR("fail_add_partition_1") ||
ERROR_INJECT("add_partition_1") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
ERROR_INJECT_CRASH("crash_add_partition_2") ||
ERROR_INJECT_ERROR("fail_add_partition_2") ||
ERROR_INJECT("add_partition_2") ||
wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) ||
ERROR_INJECT_CRASH("crash_add_partition_3") ||
ERROR_INJECT_ERROR("fail_add_partition_3") ||
ERROR_INJECT("add_partition_3") ||
write_log_add_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_4") ||
ERROR_INJECT_ERROR("fail_add_partition_4") ||
ERROR_INJECT("add_partition_4") ||
mysql_change_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_5") ||
ERROR_INJECT_ERROR("fail_add_partition_5") ||
ERROR_INJECT("add_partition_5") ||
alter_close_table(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_6") ||
ERROR_INJECT_ERROR("fail_add_partition_6") ||
ERROR_INJECT_CRASH("crash_add_partition_7") ||
ERROR_INJECT_ERROR("fail_add_partition_7") ||
ERROR_INJECT("add_partition_6") ||
ERROR_INJECT("add_partition_7") ||
write_log_rename_frm(lpt) ||
(action_completed= TRUE, FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_8") ||
ERROR_INJECT_ERROR("fail_add_partition_8") ||
ERROR_INJECT("add_partition_8") ||
(frm_install= TRUE, FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
log_partition_alter_to_ddl_log(lpt) ||
(frm_install= FALSE, FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_9") ||
ERROR_INJECT_ERROR("fail_add_partition_9") ||
ERROR_INJECT("add_partition_9") ||
(write_log_completed(lpt, FALSE), FALSE) ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_add_partition_10") ||
ERROR_INJECT_ERROR("fail_add_partition_10"))
ERROR_INJECT("add_partition_10"))
{
handle_alter_part_error(lpt, action_completed, FALSE, frm_install);
goto err;
@ -7616,47 +7588,35 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
13) Complete query.
*/
if (write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_1") ||
ERROR_INJECT_ERROR("fail_change_partition_1") ||
ERROR_INJECT("change_partition_1") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
ERROR_INJECT_CRASH("crash_change_partition_2") ||
ERROR_INJECT_ERROR("fail_change_partition_2") ||
ERROR_INJECT("change_partition_2") ||
write_log_add_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_3") ||
ERROR_INJECT_ERROR("fail_change_partition_3") ||
ERROR_INJECT("change_partition_3") ||
mysql_change_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_4") ||
ERROR_INJECT_ERROR("fail_change_partition_4") ||
ERROR_INJECT("change_partition_4") ||
wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) ||
ERROR_INJECT_CRASH("crash_change_partition_5") ||
ERROR_INJECT_ERROR("fail_change_partition_5") ||
ERROR_INJECT("change_partition_5") ||
alter_close_table(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_6") ||
ERROR_INJECT_ERROR("fail_change_partition_6") ||
ERROR_INJECT("change_partition_6") ||
write_log_final_change_partition(lpt) ||
(action_completed= TRUE, FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_7") ||
ERROR_INJECT_ERROR("fail_change_partition_7") ||
ERROR_INJECT_CRASH("crash_change_partition_8") ||
ERROR_INJECT_ERROR("fail_change_partition_8") ||
ERROR_INJECT("change_partition_7") ||
ERROR_INJECT("change_partition_8") ||
((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
log_partition_alter_to_ddl_log(lpt) ||
(frm_install= FALSE, FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_9") ||
ERROR_INJECT_ERROR("fail_change_partition_9") ||
ERROR_INJECT("change_partition_9") ||
mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_10") ||
ERROR_INJECT_ERROR("fail_change_partition_10") ||
ERROR_INJECT("change_partition_10") ||
mysql_rename_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_11") ||
ERROR_INJECT_ERROR("fail_change_partition_11") ||
ERROR_INJECT("change_partition_11") ||
(write_log_completed(lpt, FALSE), FALSE) ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_change_partition_12") ||
ERROR_INJECT_ERROR("fail_change_partition_12"))
ERROR_INJECT("change_partition_12"))
{
handle_alter_part_error(lpt, action_completed, FALSE, frm_install);
goto err;

View file

@ -810,10 +810,9 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
DBUG_ASSERT(!create_info->tmp_table());
if (ddl_log_create_table(thd, part_info, create_info->db_type, &new_path,
&alter_ctx->new_db, &alter_ctx->new_name, true) ||
ERROR_INJECT_ERROR("fail_create_before_create_frm"))
ERROR_INJECT("create_before_create_frm"))
DBUG_RETURN(TRUE);
debug_crash_here("ddl_log_create_before_create_frm");
if (mysql_prepare_create_table(thd, create_info, lpt->alter_info,
&lpt->db_options, file,
&lpt->key_info_buffer, &lpt->key_count,
@ -832,18 +831,17 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
thd->work_part_info= work_part_info;
create_info->db_type= db_type;
debug_crash_here("ddl_log_alter_partition_after_create_frm");
ERROR_INJECT("alter_partition_after_create_frm");
error= writefile(frm_name, alter_ctx->new_db.str, alter_ctx->new_name.str,
create_info->tmp_table(), frm.str, frm.length);
my_free((void *) frm.str);
if (unlikely(error) || ERROR_INJECT_ERROR("fail_alter_partition_after_write_frm"))
if (unlikely(error) || ERROR_INJECT("alter_partition_after_write_frm"))
{
mysql_file_delete(key_file_frm, frm_name, MYF(0));
DBUG_RETURN(TRUE);
}
debug_crash_here("ddl_log_alter_partition_after_write_frm");
DBUG_RETURN(false);
}
if (flags & WFRM_BACKUP_ORIGINAL)

View file

@ -20,10 +20,9 @@
#include <my_sys.h> // pthread_mutex_t
#include "m_string.h" // LEX_CUSTRING
#define ERROR_INJECT_CRASH(code) \
(DBUG_IF(code) && (DBUG_SUICIDE(), false))
#define ERROR_INJECT_ERROR(code) \
(DBUG_IF(code) && (my_error(ER_UNKNOWN_ERROR, MYF(0)), 1))
#define ERROR_INJECT(code) \
((DBUG_IF("crash_" code) && (DBUG_SUICIDE(), 0)) || \
(DBUG_IF("fail_" code) && (my_error(ER_UNKNOWN_ERROR, MYF(0)), 1)))
class Alter_info;
class Alter_table_ctx;