mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
WL 2826: Error handling of ALTER TABLE for partitioning
Error handling Crash if any error after reaching beyond certain point in ALTER TABLE processing sql/ha_partition.cc: Error handling Crash if any error after reaching beyond certain point in ALTER TABLE processing sql/sql_partition.cc: Error handling Crash if any error after reaching beyond certain point in ALTER TABLE processing
This commit is contained in:
@@ -584,7 +584,7 @@ int ha_partition::drop_partitions(const char *path)
|
||||
uint no_subparts= m_part_info->no_subparts;
|
||||
uint i= 0;
|
||||
uint name_variant;
|
||||
int error= 1;
|
||||
int error= 0;
|
||||
bool reorged_parts= (m_reorged_parts > 0);
|
||||
bool temp_partitions= (m_part_info->temp_partitions.elements > 0);
|
||||
DBUG_ENTER("ha_partition::drop_partitions");
|
||||
@@ -632,7 +632,7 @@ int ha_partition::drop_partitions(const char *path)
|
||||
else
|
||||
file= m_file[part];
|
||||
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
|
||||
error= file->delete_table((const char *) part_name_buff);
|
||||
error+= file->delete_table((const char *) part_name_buff);
|
||||
} while (++j < no_subparts);
|
||||
}
|
||||
else
|
||||
@@ -645,7 +645,7 @@ int ha_partition::drop_partitions(const char *path)
|
||||
else
|
||||
file= m_file[i];
|
||||
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
|
||||
error= file->delete_table((const char *) part_name_buff);
|
||||
error+= file->delete_table((const char *) part_name_buff);
|
||||
}
|
||||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
part_elem->part_state= PART_NORMAL;
|
||||
@@ -687,7 +687,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
uint no_subparts= m_part_info->no_subparts;
|
||||
uint i= 0;
|
||||
uint j= 0;
|
||||
int error= 1;
|
||||
int error= 0;
|
||||
uint temp_partitions= m_part_info->temp_partitions.elements;
|
||||
handler *file;
|
||||
partition_element *part_elem, *sub_elem;
|
||||
@@ -715,7 +715,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
NORMAL_PART_NAME);
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
error+= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
} while (++j < no_subparts);
|
||||
}
|
||||
@@ -730,7 +730,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
error+= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
}
|
||||
} while (++i < temp_partitions);
|
||||
@@ -765,7 +765,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
RENAMED_PART_NAME);
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
error+= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
}
|
||||
file= m_new_file[part];
|
||||
@@ -775,7 +775,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
TEMP_PART_NAME);
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
error= file->rename_table((const char *) part_name_buff,
|
||||
error+= file->rename_table((const char *) part_name_buff,
|
||||
(const char *) norm_name_buff);
|
||||
} while (++j < no_subparts);
|
||||
}
|
||||
@@ -792,7 +792,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
error+= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
}
|
||||
file= m_new_file[i];
|
||||
@@ -801,7 +801,7 @@ int ha_partition::rename_partitions(const char *path)
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
error= file->rename_table((const char *) part_name_buff,
|
||||
error+= file->rename_table((const char *) part_name_buff,
|
||||
(const char *) norm_name_buff);
|
||||
}
|
||||
}
|
||||
|
@@ -5749,12 +5749,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
We insert Error injections at all places where it could be interesting
|
||||
to test if recovery is properly done.
|
||||
*/
|
||||
bool not_completed= TRUE;
|
||||
if (write_log_drop_shadow_frm(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_1") ||
|
||||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_2") ||
|
||||
write_log_drop_partition(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_3") ||
|
||||
(not_completed= FALSE) ||
|
||||
abort_and_upgrade_lock(lpt) ||
|
||||
((!thd->lex->no_write_to_binlog) &&
|
||||
(write_bin_log(thd, FALSE,
|
||||
@@ -5763,7 +5765,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
|
||||
(close_open_tables_and_downgrade(lpt), FALSE) ||
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_5") ||
|
||||
table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE) ||
|
||||
(table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE), FALSE) ||
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_6") ||
|
||||
mysql_drop_partitions(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_7") ||
|
||||
@@ -5771,6 +5773,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
ERROR_INJECT_CRASH("crash_drop_partition_8") ||
|
||||
(mysql_wait_completed_table(lpt, table), FALSE))
|
||||
{
|
||||
if (!not_completed)
|
||||
abort();
|
||||
fast_alter_partition_error_handler(lpt);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
@@ -5805,6 +5809,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
8) Remove entries from table log
|
||||
9) Complete query
|
||||
*/
|
||||
bool not_completed= TRUE;
|
||||
if (write_log_add_change_partition(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_add_partition_1") ||
|
||||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
|
||||
@@ -5817,6 +5822,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
thd->query, thd->query_length), FALSE)) ||
|
||||
ERROR_INJECT_CRASH("crash_add_partition_4") ||
|
||||
write_log_rename_frm(lpt) ||
|
||||
(not_completed= FALSE) ||
|
||||
ERROR_INJECT_CRASH("crash_add_partition_5") ||
|
||||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
|
||||
ERROR_INJECT_CRASH("crash_add_partition_6") ||
|
||||
@@ -5824,6 +5830,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
write_log_completed(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_add_partition_7"))
|
||||
{
|
||||
if (!not_completed)
|
||||
abort();
|
||||
fast_alter_partition_error_handler(lpt);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
@@ -5883,7 +5891,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
13)Wait until all accesses using the old frm file has completed
|
||||
14)Complete query
|
||||
*/
|
||||
|
||||
bool not_completed= TRUE;
|
||||
if (write_log_add_change_partition(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_1") ||
|
||||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
|
||||
@@ -5892,14 +5900,15 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
ERROR_INJECT_CRASH("crash_change_partition_3") ||
|
||||
write_log_final_change_partition(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_4") ||
|
||||
(not_completed= FALSE) ||
|
||||
abort_and_upgrade_lock(lpt) ||
|
||||
table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_5") ||
|
||||
mysql_rename_partitions(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_6") ||
|
||||
((!thd->lex->no_write_to_binlog) &&
|
||||
(write_bin_log(thd, FALSE,
|
||||
thd->query, thd->query_length), FALSE)) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_5") ||
|
||||
(table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE), FALSE) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_6") ||
|
||||
mysql_rename_partitions(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_7") ||
|
||||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_8") ||
|
||||
@@ -5911,6 +5920,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
ERROR_INJECT_CRASH("crash_change_partition_11") ||
|
||||
(mysql_wait_completed_table(lpt, table), FALSE))
|
||||
{
|
||||
if (!not_completed)
|
||||
abort();
|
||||
fast_alter_partition_error_handler(lpt);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user