Commit f03fee06 authored by Monty's avatar Monty

Improve error messages from Aria

- Error on commit now returns HA_ERR_COMMIT_ERROR instead of
  HA_ERR_INTERNAL_ERROR
- If checkpoint fails, it will now print out where it failed.
parent 6be0ddae
...@@ -79,3 +79,4 @@ ...@@ -79,3 +79,4 @@
{ "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" }, { "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" },
{ "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" }, { "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" },
{ "HA_ERR_INCOMPATIBLE_DEFINITION", HA_ERR_INCOMPATIBLE_DEFINITION, "" }, { "HA_ERR_INCOMPATIBLE_DEFINITION", HA_ERR_INCOMPATIBLE_DEFINITION, "" },
{ "HA_ERR_COMMIT_ERROR", HA_ERR_COMMIT_ERROR, "" },
...@@ -525,7 +525,8 @@ enum ha_base_keytype { ...@@ -525,7 +525,8 @@ enum ha_base_keytype {
#define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */ #define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */
#define HA_ERR_SEQUENCE_INVALID_DATA 195 #define HA_ERR_SEQUENCE_INVALID_DATA 195
#define HA_ERR_SEQUENCE_RUN_OUT 196 #define HA_ERR_SEQUENCE_RUN_OUT 196
#define HA_ERR_LAST 196 /* Copy of last error nr * */ #define HA_ERR_COMMIT_ERROR 197
#define HA_ERR_LAST 197 /* Copy of last error nr * */
/* Number of different errors */ /* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
......
...@@ -107,7 +107,8 @@ static const char *handler_error_messages[]= ...@@ -107,7 +107,8 @@ static const char *handler_error_messages[]=
"Foreign key cascade delete/update exceeds max depth", "Foreign key cascade delete/update exceeds max depth",
"Tablespace is missing for a table", "Tablespace is missing for a table",
"Sequence has been run out", "Sequence has been run out",
"Sequence values are conflicting" "Sequence values are conflicting",
"Error during commit"
}; };
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */ #endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
...@@ -4217,6 +4217,9 @@ void handler::print_error(int error, myf errflag) ...@@ -4217,6 +4217,9 @@ void handler::print_error(int error, myf errflag)
case HA_ERR_TABLE_IN_FK_CHECK: case HA_ERR_TABLE_IN_FK_CHECK:
textno= ER_TABLE_IN_FK_CHECK; textno= ER_TABLE_IN_FK_CHECK;
break; break;
case HA_ERR_COMMIT_ERROR:
textno= ER_ERROR_DURING_COMMIT;
break;
default: default:
{ {
/* The error was "unknown" to this function. /* The error was "unknown" to this function.
......
...@@ -2904,7 +2904,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) ...@@ -2904,7 +2904,7 @@ int ha_maria::external_lock(THD *thd, int lock_type)
if (file->autocommit) if (file->autocommit)
{ {
if (ma_commit(trn)) if (ma_commit(trn))
result= HA_ERR_INTERNAL_ERROR; result= HA_ERR_COMMIT_ERROR;
thd_set_ha_data(thd, maria_hton, 0); thd_set_ha_data(thd, maria_hton, 0);
} }
} }
...@@ -3043,7 +3043,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) ...@@ -3043,7 +3043,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)
error= 0; error= 0;
if (unlikely(ma_commit(trn))) if (unlikely(ma_commit(trn)))
error= 1; error= HA_ERR_COMMIT_ERROR;
if (!new_trn) if (!new_trn)
{ {
reset_thd_trn(thd, used_tables); reset_thd_trn(thd, used_tables);
...@@ -3480,7 +3480,7 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)), ...@@ -3480,7 +3480,7 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
THD *thd, bool all) THD *thd, bool all)
{ {
TRN *trn= THD_TRN; TRN *trn= THD_TRN;
int res; int res= 0;
MARIA_HA *used_instances; MARIA_HA *used_instances;
DBUG_ENTER("maria_commit"); DBUG_ENTER("maria_commit");
...@@ -3499,7 +3499,8 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)), ...@@ -3499,7 +3499,8 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
trnman_reset_locked_tables(trn, 0); trnman_reset_locked_tables(trn, 0);
trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED); trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED);
trn->used_instances= 0; trn->used_instances= 0;
res= ma_commit(trn); if (ma_commit(trn))
res= HA_ERR_COMMIT_ERROR;
reset_thd_trn(thd, used_instances); reset_thd_trn(thd, used_instances);
thd_set_ha_data(thd, maria_hton, 0); thd_set_ha_data(thd, maria_hton, 0);
DBUG_RETURN(res); DBUG_RETURN(res);
......
...@@ -153,8 +153,10 @@ int ma_checkpoint_execute(CHECKPOINT_LEVEL level, my_bool no_wait) ...@@ -153,8 +153,10 @@ int ma_checkpoint_execute(CHECKPOINT_LEVEL level, my_bool no_wait)
static int really_execute_checkpoint(void) static int really_execute_checkpoint(void)
{ {
uint i, error= 0; uint i, error= 0;
int error_errno= 0;
/** @brief checkpoint_start_log_horizon will be stored there */ /** @brief checkpoint_start_log_horizon will be stored there */
char *ptr; char *ptr;
const char *error_place= 0;
LEX_STRING record_pieces[4]; /**< only malloc-ed pieces */ LEX_STRING record_pieces[4]; /**< only malloc-ed pieces */
LSN min_page_rec_lsn, min_trn_rec_lsn, min_first_undo_lsn; LSN min_page_rec_lsn, min_trn_rec_lsn, min_first_undo_lsn;
TRANSLOG_ADDRESS checkpoint_start_log_horizon; TRANSLOG_ADDRESS checkpoint_start_log_horizon;
...@@ -191,13 +193,19 @@ static int really_execute_checkpoint(void) ...@@ -191,13 +193,19 @@ static int really_execute_checkpoint(void)
&record_pieces[1], &record_pieces[1],
&min_trn_rec_lsn, &min_trn_rec_lsn,
&min_first_undo_lsn))) &min_first_undo_lsn)))
{
error_place= "trnman_collect_transaction";
goto err; goto err;
}
/* STEP 3: fetch information about table files */ /* STEP 3: fetch information about table files */
if (unlikely(collect_tables(&record_pieces[2], if (unlikely(collect_tables(&record_pieces[2],
checkpoint_start_log_horizon))) checkpoint_start_log_horizon)))
{
error_place= "collect_tables";
goto err; goto err;
}
/* STEP 4: fetch information about dirty pages */ /* STEP 4: fetch information about dirty pages */
...@@ -211,7 +219,10 @@ static int really_execute_checkpoint(void) ...@@ -211,7 +219,10 @@ static int really_execute_checkpoint(void)
if (unlikely(pagecache_collect_changed_blocks_with_lsn(maria_pagecache, if (unlikely(pagecache_collect_changed_blocks_with_lsn(maria_pagecache,
&record_pieces[3], &record_pieces[3],
&min_page_rec_lsn))) &min_page_rec_lsn)))
{
error_place= "collect_pages";
goto err; goto err;
}
/* LAST STEP: now write the checkpoint log record */ /* LAST STEP: now write the checkpoint log record */
...@@ -240,7 +251,10 @@ static int really_execute_checkpoint(void) ...@@ -240,7 +251,10 @@ static int really_execute_checkpoint(void)
sizeof(log_array)/sizeof(log_array[0]), sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL, NULL) || log_array, NULL, NULL) ||
translog_flush(lsn))) translog_flush(lsn)))
{
error_place= "translog_write_record";
goto err; goto err;
}
translog_lock(); translog_lock();
/* /*
This cannot be done as a inwrite_rec_hook of LOGREC_CHECKPOINT, because This cannot be done as a inwrite_rec_hook of LOGREC_CHECKPOINT, because
...@@ -251,6 +265,8 @@ static int really_execute_checkpoint(void) ...@@ -251,6 +265,8 @@ static int really_execute_checkpoint(void)
max_trid_in_control_file, max_trid_in_control_file,
recovery_failures))) recovery_failures)))
{ {
error_place= "ma_control_file_write";
error_errno= my_errno;
translog_unlock(); translog_unlock();
goto err; goto err;
} }
...@@ -287,7 +303,9 @@ static int really_execute_checkpoint(void) ...@@ -287,7 +303,9 @@ static int really_execute_checkpoint(void)
err: err:
error= 1; error= 1;
ma_message_no_user(0, "checkpoint failed"); my_printf_error(HA_ERR_GENERIC, "Aria engine: checkpoint failed at %s with "
"error %d", MYF(ME_ERROR_LOG),
error_place, (error_errno ? error_errno : my_errno));
/* we were possibly not able to determine what pages to flush */ /* we were possibly not able to determine what pages to flush */
pages_to_flush_before_next_checkpoint= 0; pages_to_flush_before_next_checkpoint= 0;
......
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