Skip to content

Commit

Permalink
Small improvements to aria recovery
Browse files Browse the repository at this point in the history
I spent 4 hours on work and 12 hours of testing to try to find
the reason for aria crashing in recovery when starting a new test,
in which case the 'data directory' should be a copy of "install.db",
but aria_log.00000001 content was not correct.

The following changes are mostly done to make it a bit easier to find out
more in case of future similar crashes:

- Mark last_checkpoint_lsn volatile (safety).
- Write checkpoint message to aria_recovery.trace
- When compling with DBUG and with HAVE_DBUG_TRANSLOG_SRC,
  use checksum's for Aria log pages. We cannot have it on by default
  for DBUG servers yet as there is bugs when changing CRC between
  restarts.
- Added a message to mtr --verbose when copying the data directory.
- Removed extra linefeed in Aria recovery message (cleanup)
  • Loading branch information
montywi authored and spetrunia committed Feb 3, 2023
1 parent 66dde8a commit cbf60db
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions mysql-test/mariadb-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,7 @@ ($)
# Copy datadir from installed system db
my $path= ($opt_parallel == 1) ? "$opt_vardir" : "$opt_vardir/..";
my $install_db= "$path/install.db";
mtr_verbose("copying $install_db to $datadir");
copytree($install_db, $datadir) if -d $install_db;
mtr_error("Failed to copy system db to '$datadir'") unless -d $datadir;
}
Expand Down
2 changes: 1 addition & 1 deletion storage/maria/ma_control_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ one should increment the control file version number.
This LSN serves for the two-checkpoint rule, and also to find the
checkpoint record when doing a recovery.
*/
LSN last_checkpoint_lsn= LSN_IMPOSSIBLE;
volatile LSN last_checkpoint_lsn= LSN_IMPOSSIBLE;
uint32 last_logno= FILENO_IMPOSSIBLE;
/**
The maximum transaction id given to a transaction. It is only updated at
Expand Down
2 changes: 1 addition & 1 deletion storage/maria/ma_control_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ C_MODE_START
LSN of the last checkoint
(if last_checkpoint_lsn == LSN_IMPOSSIBLE then there was never a checkpoint)
*/
extern LSN last_checkpoint_lsn;
extern volatile LSN last_checkpoint_lsn;
/*
Last log number (if last_logno == FILENO_IMPOSSIBLE then there is no log
file yet)
Expand Down
4 changes: 4 additions & 0 deletions storage/maria/ma_loghandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
/* minimum possible transaction log size */
#define TRANSLOG_MIN_FILE_SIZE (8*MB)
/* transaction log default flags (TODO: make it global variable) */
#ifdef HAVE_DBUG_TRANSLOG_CRC
#define TRANSLOG_DEFAULT_FLAGS IF_DBUG(TRANSLOG_PAGE_CRC,0)
#else
#define TRANSLOG_DEFAULT_FLAGS 0
#endif

/*
Transaction log flags.
Expand Down
12 changes: 7 additions & 5 deletions storage/maria/ma_recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void new_transaction(uint16 sid, TrID long_id, LSN undo_lsn,
static int new_table(uint16 sid, const char *name, LSN lsn_of_file_id);
static int new_page(uint32 fileid, pgcache_page_no_t pageid, LSN rec_lsn,
struct st_dirty_page *dirty_page);
static int close_all_tables(void);
static int close_all_tables(my_bool force_end_newline);
static my_bool close_one_table(const char *name, TRANSLOG_ADDRESS addr);
static void print_redo_phase_progress(TRANSLOG_ADDRESS addr);
static void delete_all_transactions();
Expand Down Expand Up @@ -467,7 +467,7 @@ int maria_apply_log(LSN from_lsn, LSN end_redo_lsn, LSN end_undo_lsn,
we don't use maria_panic() because it would maria_end(), and Recovery does
not want that (we want to keep some modules initialized for runtime).
*/
if (close_all_tables())
if (close_all_tables(0))
{
ma_message_no_user(0, "closing of tables failed");
goto err;
Expand Down Expand Up @@ -495,6 +495,8 @@ int maria_apply_log(LSN from_lsn, LSN end_redo_lsn, LSN end_undo_lsn,
/* No dirty pages, all tables are closed, no active transactions, save: */
if (ma_checkpoint_execute(CHECKPOINT_FULL, FALSE))
goto err;
tprint(tracef, "checkpoint done at " LSN_FMT "\n",
LSN_IN_PARTS(last_checkpoint_lsn));
}

goto end;
Expand All @@ -505,7 +507,7 @@ int maria_apply_log(LSN from_lsn, LSN end_redo_lsn, LSN end_undo_lsn,
delete_all_transactions();
if (!abort_message_printed)
error= 1;
if (close_all_tables())
if (close_all_tables(1))
{
ma_message_no_user(0, "closing of tables failed");
}
Expand Down Expand Up @@ -3472,7 +3474,7 @@ static int new_page(uint32 fileid, pgcache_page_no_t pageid, LSN rec_lsn,
}


static int close_all_tables(void)
static int close_all_tables(my_bool force_end_newline)
{
int error= 0;
uint count= 0;
Expand Down Expand Up @@ -3537,7 +3539,7 @@ static int close_all_tables(void)
}
}
end:
if (recovery_message_printed == REC_MSG_FLUSH)
if (recovery_message_printed == REC_MSG_FLUSH && (force_end_newline || error))
{
fputc('\n', stderr);
fflush(stderr);
Expand Down
2 changes: 1 addition & 1 deletion storage/maria/ma_recovery_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void eprint(FILE *trace_file __attribute__ ((unused)),
if (!trace_file)
trace_file= stderr;

if (procent_printed)
if (procent_printed && trace_file == stderr)
{
procent_printed= 0;
/* In silent mode, print on another line than the 0% 10% 20% line */
Expand Down

0 comments on commit cbf60db

Please sign in to comment.