Skip to content

Commit f03fee0

Browse files
committed
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.
1 parent 6be0dda commit f03fee0

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

include/handler_ername.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@
7979
{ "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" },
8080
{ "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" },
8181
{ "HA_ERR_INCOMPATIBLE_DEFINITION", HA_ERR_INCOMPATIBLE_DEFINITION, "" },
82+
{ "HA_ERR_COMMIT_ERROR", HA_ERR_COMMIT_ERROR, "" },

include/my_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ enum ha_base_keytype {
525525
#define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */
526526
#define HA_ERR_SEQUENCE_INVALID_DATA 195
527527
#define HA_ERR_SEQUENCE_RUN_OUT 196
528-
#define HA_ERR_LAST 196 /* Copy of last error nr * */
528+
#define HA_ERR_COMMIT_ERROR 197
529+
#define HA_ERR_LAST 197 /* Copy of last error nr * */
529530

530531
/* Number of different errors */
531532
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)

include/my_handler_errors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ static const char *handler_error_messages[]=
107107
"Foreign key cascade delete/update exceeds max depth",
108108
"Tablespace is missing for a table",
109109
"Sequence has been run out",
110-
"Sequence values are conflicting"
110+
"Sequence values are conflicting",
111+
"Error during commit"
111112
};
112113

113114
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */

sql/handler.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,6 +4217,9 @@ void handler::print_error(int error, myf errflag)
42174217
case HA_ERR_TABLE_IN_FK_CHECK:
42184218
textno= ER_TABLE_IN_FK_CHECK;
42194219
break;
4220+
case HA_ERR_COMMIT_ERROR:
4221+
textno= ER_ERROR_DURING_COMMIT;
4222+
break;
42204223
default:
42214224
{
42224225
/* The error was "unknown" to this function.

storage/maria/ha_maria.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,7 +2904,7 @@ int ha_maria::external_lock(THD *thd, int lock_type)
29042904
if (file->autocommit)
29052905
{
29062906
if (ma_commit(trn))
2907-
result= HA_ERR_INTERNAL_ERROR;
2907+
result= HA_ERR_COMMIT_ERROR;
29082908
thd_set_ha_data(thd, maria_hton, 0);
29092909
}
29102910
}
@@ -3043,7 +3043,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)
30433043

30443044
error= 0;
30453045
if (unlikely(ma_commit(trn)))
3046-
error= 1;
3046+
error= HA_ERR_COMMIT_ERROR;
30473047
if (!new_trn)
30483048
{
30493049
reset_thd_trn(thd, used_tables);
@@ -3480,7 +3480,7 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
34803480
THD *thd, bool all)
34813481
{
34823482
TRN *trn= THD_TRN;
3483-
int res;
3483+
int res= 0;
34843484
MARIA_HA *used_instances;
34853485
DBUG_ENTER("maria_commit");
34863486

@@ -3499,7 +3499,8 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
34993499
trnman_reset_locked_tables(trn, 0);
35003500
trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED);
35013501
trn->used_instances= 0;
3502-
res= ma_commit(trn);
3502+
if (ma_commit(trn))
3503+
res= HA_ERR_COMMIT_ERROR;
35033504
reset_thd_trn(thd, used_instances);
35043505
thd_set_ha_data(thd, maria_hton, 0);
35053506
DBUG_RETURN(res);

storage/maria/ma_checkpoint.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ int ma_checkpoint_execute(CHECKPOINT_LEVEL level, my_bool no_wait)
153153
static int really_execute_checkpoint(void)
154154
{
155155
uint i, error= 0;
156+
int error_errno= 0;
156157
/** @brief checkpoint_start_log_horizon will be stored there */
157158
char *ptr;
159+
const char *error_place= 0;
158160
LEX_STRING record_pieces[4]; /**< only malloc-ed pieces */
159161
LSN min_page_rec_lsn, min_trn_rec_lsn, min_first_undo_lsn;
160162
TRANSLOG_ADDRESS checkpoint_start_log_horizon;
@@ -191,13 +193,19 @@ static int really_execute_checkpoint(void)
191193
&record_pieces[1],
192194
&min_trn_rec_lsn,
193195
&min_first_undo_lsn)))
196+
{
197+
error_place= "trnman_collect_transaction";
194198
goto err;
199+
}
195200

196201

197202
/* STEP 3: fetch information about table files */
198203
if (unlikely(collect_tables(&record_pieces[2],
199204
checkpoint_start_log_horizon)))
205+
{
206+
error_place= "collect_tables";
200207
goto err;
208+
}
201209

202210

203211
/* STEP 4: fetch information about dirty pages */
@@ -211,7 +219,10 @@ static int really_execute_checkpoint(void)
211219
if (unlikely(pagecache_collect_changed_blocks_with_lsn(maria_pagecache,
212220
&record_pieces[3],
213221
&min_page_rec_lsn)))
222+
{
223+
error_place= "collect_pages";
214224
goto err;
225+
}
215226

216227

217228
/* LAST STEP: now write the checkpoint log record */
@@ -240,7 +251,10 @@ static int really_execute_checkpoint(void)
240251
sizeof(log_array)/sizeof(log_array[0]),
241252
log_array, NULL, NULL) ||
242253
translog_flush(lsn)))
254+
{
255+
error_place= "translog_write_record";
243256
goto err;
257+
}
244258
translog_lock();
245259
/*
246260
This cannot be done as a inwrite_rec_hook of LOGREC_CHECKPOINT, because
@@ -251,6 +265,8 @@ static int really_execute_checkpoint(void)
251265
max_trid_in_control_file,
252266
recovery_failures)))
253267
{
268+
error_place= "ma_control_file_write";
269+
error_errno= my_errno;
254270
translog_unlock();
255271
goto err;
256272
}
@@ -287,7 +303,9 @@ static int really_execute_checkpoint(void)
287303

288304
err:
289305
error= 1;
290-
ma_message_no_user(0, "checkpoint failed");
306+
my_printf_error(HA_ERR_GENERIC, "Aria engine: checkpoint failed at %s with "
307+
"error %d", MYF(ME_ERROR_LOG),
308+
error_place, (error_errno ? error_errno : my_errno));
291309
/* we were possibly not able to determine what pages to flush */
292310
pages_to_flush_before_next_checkpoint= 0;
293311

0 commit comments

Comments
 (0)