Commit 4bef9c0e authored by unknown's avatar unknown

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
parent ddb14e0f
...@@ -584,7 +584,7 @@ int ha_partition::drop_partitions(const char *path) ...@@ -584,7 +584,7 @@ int ha_partition::drop_partitions(const char *path)
uint no_subparts= m_part_info->no_subparts; uint no_subparts= m_part_info->no_subparts;
uint i= 0; uint i= 0;
uint name_variant; uint name_variant;
int error= 1; int error= 0;
bool reorged_parts= (m_reorged_parts > 0); bool reorged_parts= (m_reorged_parts > 0);
bool temp_partitions= (m_part_info->temp_partitions.elements > 0); bool temp_partitions= (m_part_info->temp_partitions.elements > 0);
DBUG_ENTER("ha_partition::drop_partitions"); DBUG_ENTER("ha_partition::drop_partitions");
...@@ -632,7 +632,7 @@ int ha_partition::drop_partitions(const char *path) ...@@ -632,7 +632,7 @@ int ha_partition::drop_partitions(const char *path)
else else
file= m_file[part]; file= m_file[part];
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff)); 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); } while (++j < no_subparts);
} }
else else
...@@ -645,7 +645,7 @@ int ha_partition::drop_partitions(const char *path) ...@@ -645,7 +645,7 @@ int ha_partition::drop_partitions(const char *path)
else else
file= m_file[i]; file= m_file[i];
DBUG_PRINT("info", ("Drop partition %s", part_name_buff)); 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) if (part_elem->part_state == PART_IS_CHANGED)
part_elem->part_state= PART_NORMAL; part_elem->part_state= PART_NORMAL;
...@@ -687,7 +687,7 @@ int ha_partition::rename_partitions(const char *path) ...@@ -687,7 +687,7 @@ int ha_partition::rename_partitions(const char *path)
uint no_subparts= m_part_info->no_subparts; uint no_subparts= m_part_info->no_subparts;
uint i= 0; uint i= 0;
uint j= 0; uint j= 0;
int error= 1; int error= 0;
uint temp_partitions= m_part_info->temp_partitions.elements; uint temp_partitions= m_part_info->temp_partitions.elements;
handler *file; handler *file;
partition_element *part_elem, *sub_elem; partition_element *part_elem, *sub_elem;
...@@ -715,8 +715,8 @@ int ha_partition::rename_partitions(const char *path) ...@@ -715,8 +715,8 @@ int ha_partition::rename_partitions(const char *path)
NORMAL_PART_NAME); NORMAL_PART_NAME);
DBUG_PRINT("info", ("Rename subpartition from %s to %s", DBUG_PRINT("info", ("Rename subpartition from %s to %s",
norm_name_buff, part_name_buff)); 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); (const char *) part_name_buff);
} while (++j < no_subparts); } while (++j < no_subparts);
} }
else else
...@@ -730,8 +730,8 @@ int ha_partition::rename_partitions(const char *path) ...@@ -730,8 +730,8 @@ int ha_partition::rename_partitions(const char *path)
TRUE); TRUE);
DBUG_PRINT("info", ("Rename partition from %s to %s", DBUG_PRINT("info", ("Rename partition from %s to %s",
norm_name_buff, part_name_buff)); 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); (const char *) part_name_buff);
} }
} while (++i < temp_partitions); } while (++i < temp_partitions);
} }
...@@ -765,8 +765,8 @@ int ha_partition::rename_partitions(const char *path) ...@@ -765,8 +765,8 @@ int ha_partition::rename_partitions(const char *path)
RENAMED_PART_NAME); RENAMED_PART_NAME);
DBUG_PRINT("info", ("Rename subpartition from %s to %s", DBUG_PRINT("info", ("Rename subpartition from %s to %s",
norm_name_buff, part_name_buff)); 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); (const char *) part_name_buff);
} }
file= m_new_file[part]; file= m_new_file[part];
create_subpartition_name(part_name_buff, path, create_subpartition_name(part_name_buff, path,
...@@ -775,8 +775,8 @@ int ha_partition::rename_partitions(const char *path) ...@@ -775,8 +775,8 @@ int ha_partition::rename_partitions(const char *path)
TEMP_PART_NAME); TEMP_PART_NAME);
DBUG_PRINT("info", ("Rename subpartition from %s to %s", DBUG_PRINT("info", ("Rename subpartition from %s to %s",
part_name_buff, norm_name_buff)); 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); (const char *) norm_name_buff);
} while (++j < no_subparts); } while (++j < no_subparts);
} }
else else
...@@ -792,8 +792,8 @@ int ha_partition::rename_partitions(const char *path) ...@@ -792,8 +792,8 @@ int ha_partition::rename_partitions(const char *path)
TRUE); TRUE);
DBUG_PRINT("info", ("Rename partition from %s to %s", DBUG_PRINT("info", ("Rename partition from %s to %s",
norm_name_buff, part_name_buff)); 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); (const char *) part_name_buff);
} }
file= m_new_file[i]; file= m_new_file[i];
create_partition_name(part_name_buff, path, create_partition_name(part_name_buff, path,
...@@ -801,7 +801,7 @@ int ha_partition::rename_partitions(const char *path) ...@@ -801,7 +801,7 @@ int ha_partition::rename_partitions(const char *path)
TRUE); TRUE);
DBUG_PRINT("info", ("Rename partition from %s to %s", DBUG_PRINT("info", ("Rename partition from %s to %s",
part_name_buff, norm_name_buff)); 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); (const char *) norm_name_buff);
} }
} }
......
...@@ -5749,12 +5749,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -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 We insert Error injections at all places where it could be interesting
to test if recovery is properly done. to test if recovery is properly done.
*/ */
bool not_completed= TRUE;
if (write_log_drop_shadow_frm(lpt) || if (write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_1") || ERROR_INJECT_CRASH("crash_drop_partition_1") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) || mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
ERROR_INJECT_CRASH("crash_drop_partition_2") || ERROR_INJECT_CRASH("crash_drop_partition_2") ||
write_log_drop_partition(lpt) || write_log_drop_partition(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_3") || ERROR_INJECT_CRASH("crash_drop_partition_3") ||
(not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || abort_and_upgrade_lock(lpt) ||
((!thd->lex->no_write_to_binlog) && ((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE, (write_bin_log(thd, FALSE,
...@@ -5763,7 +5765,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5763,7 +5765,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
(close_open_tables_and_downgrade(lpt), FALSE) || (close_open_tables_and_downgrade(lpt), FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_5") || 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") || ERROR_INJECT_CRASH("crash_drop_partition_6") ||
mysql_drop_partitions(lpt) || mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_7") || ERROR_INJECT_CRASH("crash_drop_partition_7") ||
...@@ -5771,6 +5773,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5771,6 +5773,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_drop_partition_8") || ERROR_INJECT_CRASH("crash_drop_partition_8") ||
(mysql_wait_completed_table(lpt, table), FALSE)) (mysql_wait_completed_table(lpt, table), FALSE))
{ {
if (!not_completed)
abort();
fast_alter_partition_error_handler(lpt); fast_alter_partition_error_handler(lpt);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -5805,6 +5809,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5805,6 +5809,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
8) Remove entries from table log 8) Remove entries from table log
9) Complete query 9) Complete query
*/ */
bool not_completed= TRUE;
if (write_log_add_change_partition(lpt) || if (write_log_add_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_1") || ERROR_INJECT_CRASH("crash_add_partition_1") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) || mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
...@@ -5817,6 +5822,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5817,6 +5822,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
thd->query, thd->query_length), FALSE)) || thd->query, thd->query_length), FALSE)) ||
ERROR_INJECT_CRASH("crash_add_partition_4") || ERROR_INJECT_CRASH("crash_add_partition_4") ||
write_log_rename_frm(lpt) || write_log_rename_frm(lpt) ||
(not_completed= FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_5") || ERROR_INJECT_CRASH("crash_add_partition_5") ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_add_partition_6") || ERROR_INJECT_CRASH("crash_add_partition_6") ||
...@@ -5824,6 +5830,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5824,6 +5830,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
write_log_completed(lpt) || write_log_completed(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_7")) ERROR_INJECT_CRASH("crash_add_partition_7"))
{ {
if (!not_completed)
abort();
fast_alter_partition_error_handler(lpt); fast_alter_partition_error_handler(lpt);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -5883,7 +5891,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -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 13)Wait until all accesses using the old frm file has completed
14)Complete query 14)Complete query
*/ */
bool not_completed= TRUE;
if (write_log_add_change_partition(lpt) || if (write_log_add_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_1") || ERROR_INJECT_CRASH("crash_change_partition_1") ||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) || mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
...@@ -5892,14 +5900,15 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5892,14 +5900,15 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_change_partition_3") || ERROR_INJECT_CRASH("crash_change_partition_3") ||
write_log_final_change_partition(lpt) || write_log_final_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_4") || ERROR_INJECT_CRASH("crash_change_partition_4") ||
(not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || 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) && ((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE, (write_bin_log(thd, FALSE,
thd->query, thd->query_length), 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") || ERROR_INJECT_CRASH("crash_change_partition_7") ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_change_partition_8") || ERROR_INJECT_CRASH("crash_change_partition_8") ||
...@@ -5911,8 +5920,10 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5911,8 +5920,10 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_change_partition_11") || ERROR_INJECT_CRASH("crash_change_partition_11") ||
(mysql_wait_completed_table(lpt, table), FALSE)) (mysql_wait_completed_table(lpt, table), FALSE))
{ {
fast_alter_partition_error_handler(lpt); if (!not_completed)
DBUG_RETURN(TRUE); abort();
fast_alter_partition_error_handler(lpt);
DBUG_RETURN(TRUE);
} }
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment