Commit 1a51fe36 authored by Michael Widenius's avatar Michael Widenius

Added variable ARIA_CHECKPOINT_LOG_ACTIVITY to allow one to specify how often...

Added variable ARIA_CHECKPOINT_LOG_ACTIVITY to allow one to specify how often we should do a checkpoint.
Added more error printing to log if log_warnings > 2
Give an error if checkpoint record is not correct,

mysql-test/suite/maria/r/compat_aliases.result:
  Added ARIA_CHECKPOINT_LOG_ACTIVITY
mysql-test/suite/maria/r/maria3.result:
  Added ARIA_CHECKPOINT_LOG_ACTIVITY
storage/maria/ha_maria.cc:
  Added ARIA_CHECKPOINT_LOG_ACTIVITY
  Added more error printing to log if log_warnings > 2
  Added db and table name to error message when printing to log
storage/maria/ma_check.c:
  Fixed bug where we didn't reset some variables between repair() calls
storage/maria/ma_checkpoint.c:
  Made maria_checkpoint_min_activity global.
  Don't do checkpoint if no data logged.
  Changed test for if we should do checkpoint to test separately for if log has grown or if we have had a lot of of cache writes.
storage/maria/ma_recovery.c:
  Give an error if checkpoint record is not correct
storage/maria/trnman.c:
  Don't print not needed long_transaction_id entries for checkpoints.
parent 8b7a63b1
......@@ -23,6 +23,7 @@ on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
where aria_vars.variable_name like 'aria_%'
and not (maria_vars.variable_value <=> aria_vars.variable_value);
variable_name variable_name
NULL ARIA_CHECKPOINT_LOG_ACTIVITY
select maria_vars.variable_name, aria_vars.variable_name from
information_schema.session_status as aria_vars left join
information_schema.session_status as maria_vars
......
......@@ -305,6 +305,7 @@ select lower(variable_name) as Variable_name, Variable_value as Value from infor
Variable_name Value
aria_block_size 8192
aria_checkpoint_interval 30
aria_checkpoint_log_activity 1048576
aria_force_start_after_recovery_failures 0
aria_group_commit none
aria_group_commit_interval 0
......
......@@ -203,11 +203,16 @@ static struct st_mysql_sys_var* system_variables_aliases[]= {
THDVAR(0, name) == MYSQL_SYSVAR_NAME(name).def_val) \
THDVAR(0, name)= name ## _alias;
/* Note:
The following list must be identical to the list for system_variables[] in ha_maria.cc
*/
void copy_variable_aliases()
{
int i= 0;
COPY_SYSVAR(block_size);
COPY_SYSVAR(checkpoint_interval);
i++; // Skip checkpoint_min_log_activity
COPY_SYSVAR(force_start_after_recovery_failures);
COPY_SYSVAR(group_commit);
COPY_SYSVAR(group_commit_interval);
......
......@@ -151,10 +151,16 @@ static MYSQL_SYSVAR_ULONG(block_size, maria_block_size,
static MYSQL_SYSVAR_ULONG(checkpoint_interval, checkpoint_interval,
PLUGIN_VAR_RQCMDARG,
"Interval between automatic checkpoints, in seconds; 0 means"
"Interval between tries to do an automatic checkpoints. In seconds; 0 means"
" 'no automatic checkpoints' which makes sense only for testing.",
NULL, update_checkpoint_interval, 30, 0, UINT_MAX, 1);
static MYSQL_SYSVAR_ULONG(checkpoint_log_activity, maria_checkpoint_min_log_activity,
PLUGIN_VAR_RQCMDARG,
"Number of bytes that the transaction log has to grow between checkpoints before a new "
"checkpoint is written to the log.",
NULL, NULL, 1024*1024, 0, UINT_MAX, 1);
static MYSQL_SYSVAR_ULONG(force_start_after_recovery_failures,
force_start_after_recovery_failures,
/*
......@@ -304,7 +310,7 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
if (!thd->vio_ok())
{
sql_print_error(fmt, args);
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
return;
}
......@@ -312,6 +318,8 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
(T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))
{
my_message(ER_NOT_KEYFILE, msgbuf, MYF(MY_WME));
if (thd->variables.log_warnings > 2)
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
return;
}
length= (uint) (strxmov(name, param->db_name, ".", param->table_name,
......@@ -330,8 +338,11 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
protocol->store(msg_type, system_charset_info);
protocol->store(msgbuf, msg_length, system_charset_info);
if (protocol->write())
sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
msgbuf);
sql_print_error("Failed on my_net_write, writing to stderr instead: %s.%s: %s\n",
param->db_name, param->table_name, msgbuf);
else if (thd->variables.log_warnings > 2)
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
return;
}
......@@ -2097,13 +2108,17 @@ bool ha_maria::check_and_repair(THD *thd)
if (crashed)
{
bool save_log_all_errors;
sql_print_warning("Recovering table: '%s'", table->s->path.str);
save_log_all_errors= thd->log_all_errors;
thd->log_all_errors|= (thd->variables.log_warnings > 2);
check_opt.flags=
((maria_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) |
(maria_recover_options & HA_RECOVER_FORCE ? 0 : T_SAFE_REPAIR) |
T_AUTO_REPAIR);
if (repair(thd, &check_opt))
error= 1;
thd->log_all_errors= save_log_all_errors;
}
pthread_mutex_lock(&LOCK_thread_count);
thd->query_string= old_query;
......@@ -3411,6 +3426,7 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name,
struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(block_size),
MYSQL_SYSVAR(checkpoint_interval),
MYSQL_SYSVAR(checkpoint_log_activity),
MYSQL_SYSVAR(force_start_after_recovery_failures),
MYSQL_SYSVAR(group_commit),
MYSQL_SYSVAR(group_commit_interval),
......@@ -3444,6 +3460,7 @@ static void update_checkpoint_interval(MYSQL_THD thd,
ma_checkpoint_init(*(ulong *)var_ptr= (ulong)(*(long *)save));
}
/**
@brief Updates group commit mode
*/
......
......@@ -2323,7 +2323,7 @@ static int initialize_variables_for_repair(HA_CHECK *param,
{
MARIA_SHARE *share= info->s;
/* Ro allow us to restore state and check how state changed */
/* Make a copy to allow us to restore state and check how state changed */
memcpy(org_share, share, sizeof(*share));
/* Repair code relies on share->state.state so we have to update it here */
......@@ -2343,6 +2343,14 @@ static int initialize_variables_for_repair(HA_CHECK *param,
param->testflag&= ~T_QUICK;
param->org_key_map= share->state.key_map;
/*
Clear check variables set by repair. This is needed to allow one to run
several repair's in a row with same param
*/
param->retry_repair= 0;
param->warning_printed= 0;
param->error_printed= 0;
sort_param->sort_info= sort_info;
sort_param->fix_datafile= ! rep_quick;
sort_param->calc_checksum= test(param->testflag & T_CALC_CHECKSUM);
......
......@@ -533,8 +533,9 @@ filter_flush_file_evenly(enum pagecache_page_type type,
risk could be that while a checkpoint happens no LRD flushing happens.
*/
static uint maria_checkpoint_min_activity= 2*1024*1024;
static ulong maria_checkpoint_min_cache_activity= 10*1024*1024;
/* Set in ha_maria.cc */
ulong maria_checkpoint_min_log_activity= 1*1024*1024;
pthread_handler_t ma_checkpoint_background(void *arg)
{
......@@ -578,6 +579,9 @@ pthread_handler_t ma_checkpoint_background(void *arg)
switch (sleeps % interval)
{
case 0:
{
TRANSLOG_ADDRESS horizon= translog_get_horizon();
/*
With background flushing evenly distributed over the time
between two checkpoints, we should have only little flushing to do
......@@ -592,10 +596,12 @@ pthread_handler_t ma_checkpoint_background(void *arg)
want to checkpoint every minute, hence the positive
maria_checkpoint_min_activity.
*/
if (((translog_get_horizon() - log_horizon_at_last_checkpoint) +
(maria_pagecache->global_cache_write -
pagecache_flushes_at_last_checkpoint) *
maria_pagecache->block_size) < maria_checkpoint_min_activity)
if (horizon != log_horizon_at_last_checkpoint &&
(ulonglong) (horizon - log_horizon_at_last_checkpoint) <=
maria_checkpoint_min_log_activity &&
((ulonglong) (maria_pagecache->global_cache_write -
pagecache_flushes_at_last_checkpoint) *
maria_pagecache->block_size) <= maria_checkpoint_min_cache_activity)
{
/* don't take checkpoint, so don't know what to flush */
pages_to_flush_before_next_checkpoint= 0;
......@@ -618,6 +624,7 @@ pthread_handler_t ma_checkpoint_background(void *arg)
and sleep until the next checkpoint.
*/
break;
}
case 1:
/* set up parameters for background page flushing */
filter_param.up_to_lsn= last_checkpoint_lsn;
......
......@@ -3215,9 +3215,11 @@ static LSN parse_checkpoint_record(LSN lsn)
tprint(tracef, "Loading data from checkpoint record at LSN (%lu,0x%lx)\n",
LSN_IN_PARTS(lsn));
if ((len= translog_read_record_header(lsn, &rec)) == RECHEADER_READ_ERROR)
if ((len= translog_read_record_header(lsn, &rec)) == RECHEADER_READ_ERROR ||
rec.type != LOGREC_CHECKPOINT)
{
tprint(tracef, "Cannot find checkpoint record where it should be\n");
eprint(tracef, "Cannot find checkpoint record at LSN (%lu,0x%lx)",
LSN_IN_PARTS(lsn));
return LSN_ERROR;
}
......
......@@ -821,6 +821,7 @@ extern uchar maria_zero_string[];
extern my_bool maria_inited, maria_in_ha_maria, maria_recovery_changed_data;
extern my_bool maria_recovery_verbose;
extern my_bool maria_assert_if_crashed_table;
extern ulong maria_checkpoint_min_log_activity;
extern HASH maria_stored_state;
extern int (*maria_create_trn_hook)(MARIA_HA *);
......
......@@ -179,6 +179,7 @@ int trnman_init(TrID initial_trid)
trnman_allocated_transactions= 0;
/* This is needed for recovery and repair */
dummy_transaction_object.min_read_from= ~(TrID) 0;
dummy_transaction_object.first_undo_lsn= TRANSACTION_LOGGED_LONG_ID;
pool= 0;
global_trid_generator= initial_trid;
......
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