Skip to content

Commit

Permalink
Improve error messages from Aria
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
montywi committed Sep 15, 2021
1 parent 6be0dda commit f03fee0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/handler_ername.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@
{ "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" },
{ "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" },
{ "HA_ERR_INCOMPATIBLE_DEFINITION", HA_ERR_INCOMPATIBLE_DEFINITION, "" },
{ "HA_ERR_COMMIT_ERROR", HA_ERR_COMMIT_ERROR, "" },
3 changes: 2 additions & 1 deletion include/my_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ enum ha_base_keytype {
#define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */
#define HA_ERR_SEQUENCE_INVALID_DATA 195
#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 */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
Expand Down
3 changes: 2 additions & 1 deletion include/my_handler_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ static const char *handler_error_messages[]=
"Foreign key cascade delete/update exceeds max depth",
"Tablespace is missing for a table",
"Sequence has been run out",
"Sequence values are conflicting"
"Sequence values are conflicting",
"Error during commit"
};

#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
3 changes: 3 additions & 0 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4217,6 +4217,9 @@ void handler::print_error(int error, myf errflag)
case HA_ERR_TABLE_IN_FK_CHECK:
textno= ER_TABLE_IN_FK_CHECK;
break;
case HA_ERR_COMMIT_ERROR:
textno= ER_ERROR_DURING_COMMIT;
break;
default:
{
/* The error was "unknown" to this function.
Expand Down
9 changes: 5 additions & 4 deletions storage/maria/ha_maria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2904,7 +2904,7 @@ int ha_maria::external_lock(THD *thd, int lock_type)
if (file->autocommit)
{
if (ma_commit(trn))
result= HA_ERR_INTERNAL_ERROR;
result= HA_ERR_COMMIT_ERROR;
thd_set_ha_data(thd, maria_hton, 0);
}
}
Expand Down Expand Up @@ -3043,7 +3043,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)

error= 0;
if (unlikely(ma_commit(trn)))
error= 1;
error= HA_ERR_COMMIT_ERROR;
if (!new_trn)
{
reset_thd_trn(thd, used_tables);
Expand Down Expand Up @@ -3480,7 +3480,7 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
THD *thd, bool all)
{
TRN *trn= THD_TRN;
int res;
int res= 0;
MARIA_HA *used_instances;
DBUG_ENTER("maria_commit");

Expand All @@ -3499,7 +3499,8 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
trnman_reset_locked_tables(trn, 0);
trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED);
trn->used_instances= 0;
res= ma_commit(trn);
if (ma_commit(trn))
res= HA_ERR_COMMIT_ERROR;
reset_thd_trn(thd, used_instances);
thd_set_ha_data(thd, maria_hton, 0);
DBUG_RETURN(res);
Expand Down
20 changes: 19 additions & 1 deletion storage/maria/ma_checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ int ma_checkpoint_execute(CHECKPOINT_LEVEL level, my_bool no_wait)
static int really_execute_checkpoint(void)
{
uint i, error= 0;
int error_errno= 0;
/** @brief checkpoint_start_log_horizon will be stored there */
char *ptr;
const char *error_place= 0;
LEX_STRING record_pieces[4]; /**< only malloc-ed pieces */
LSN min_page_rec_lsn, min_trn_rec_lsn, min_first_undo_lsn;
TRANSLOG_ADDRESS checkpoint_start_log_horizon;
Expand Down Expand Up @@ -191,13 +193,19 @@ static int really_execute_checkpoint(void)
&record_pieces[1],
&min_trn_rec_lsn,
&min_first_undo_lsn)))
{
error_place= "trnman_collect_transaction";
goto err;
}


/* STEP 3: fetch information about table files */
if (unlikely(collect_tables(&record_pieces[2],
checkpoint_start_log_horizon)))
{
error_place= "collect_tables";
goto err;
}


/* STEP 4: fetch information about dirty pages */
Expand All @@ -211,7 +219,10 @@ static int really_execute_checkpoint(void)
if (unlikely(pagecache_collect_changed_blocks_with_lsn(maria_pagecache,
&record_pieces[3],
&min_page_rec_lsn)))
{
error_place= "collect_pages";
goto err;
}


/* LAST STEP: now write the checkpoint log record */
Expand Down Expand Up @@ -240,7 +251,10 @@ static int really_execute_checkpoint(void)
sizeof(log_array)/sizeof(log_array[0]),
log_array, NULL, NULL) ||
translog_flush(lsn)))
{
error_place= "translog_write_record";
goto err;
}
translog_lock();
/*
This cannot be done as a inwrite_rec_hook of LOGREC_CHECKPOINT, because
Expand All @@ -251,6 +265,8 @@ static int really_execute_checkpoint(void)
max_trid_in_control_file,
recovery_failures)))
{
error_place= "ma_control_file_write";
error_errno= my_errno;
translog_unlock();
goto err;
}
Expand Down Expand Up @@ -287,7 +303,9 @@ static int really_execute_checkpoint(void)

err:
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 */
pages_to_flush_before_next_checkpoint= 0;

Expand Down

0 comments on commit f03fee0

Please sign in to comment.