Commit 12e53eb9 authored by serg@serg.mylan's avatar serg@serg.mylan

parallel-repair available in mysqld

parent 356b7f62
...@@ -2246,7 +2246,17 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ...@@ -2246,7 +2246,17 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
else else
rec_length=share->base.pack_reclength; rec_length=share->base.pack_reclength;
sort_info.max_records= sort_info.max_records=
((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records : /* +1 below is required hack for parallel repair mode.
The info->state->records value, that is compared later
to sort_info.max_records and cannot exceed it, is
increased in sort_key_write. In mi_repair_by_sort, sort_key_write
is called after sort_key_read, where the comparison is performed,
but in parallel mode master thread can call sort_key_write
before some other repair thread calls sort_key_read.
Furthermore I'm not even sure +1 would be enough.
May be sort_info.max_records shold be always set to max value in
parallel mode. */
((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records + 1:
(ha_rows) (sort_info.filelength/rec_length+1)); (ha_rows) (sort_info.filelength/rec_length+1));
del=info->state->del; del=info->state->del;
......
...@@ -579,11 +579,25 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -579,11 +579,25 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
{ {
local_testflag|= T_STATISTICS; local_testflag|= T_STATISTICS;
param.testflag|= T_STATISTICS; // We get this for free param.testflag|= T_STATISTICS; // We get this for free
thd->proc_info="Repair by sorting";
statistics_done=1; statistics_done=1;
if (current_thd->variables.myisam_repair_threads>1)
{
char buf[40];
/* TODO: respect myisam_repair_threads variable */
my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
thd->proc_info=buf;
error = mi_repair_parallel(&param, file, fixed_name,
param.testflag & T_QUICK);
thd->proc_info="Repair done"; // to reset proc_info, as
// it was pointing to local buffer
}
else
{
thd->proc_info="Repair by sorting";
error = mi_repair_by_sort(&param, file, fixed_name, error = mi_repair_by_sort(&param, file, fixed_name,
param.testflag & T_QUICK); param.testflag & T_QUICK);
} }
}
else else
{ {
thd->proc_info="Repair with keycache"; thd->proc_info="Repair with keycache";
......
...@@ -3145,7 +3145,7 @@ enum options { ...@@ -3145,7 +3145,7 @@ enum options {
OPT_SORT_BUFFER, OPT_TABLE_CACHE, OPT_SORT_BUFFER, OPT_TABLE_CACHE,
OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE, OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK, OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
OPT_WAIT_TIMEOUT, OPT_WAIT_TIMEOUT, OPT_MYISAM_REPAIR_THREADS,
OPT_INNODB_MIRRORED_LOG_GROUPS, OPT_INNODB_MIRRORED_LOG_GROUPS,
OPT_INNODB_LOG_FILES_IN_GROUP, OPT_INNODB_LOG_FILES_IN_GROUP,
OPT_INNODB_LOG_FILE_SIZE, OPT_INNODB_LOG_FILE_SIZE,
...@@ -3839,6 +3839,11 @@ replicating a LOAD DATA INFILE command", ...@@ -3839,6 +3839,11 @@ replicating a LOAD DATA INFILE command",
(gptr*) &global_system_variables.myisam_max_sort_file_size, (gptr*) &global_system_variables.myisam_max_sort_file_size,
(gptr*) &max_system_variables.myisam_max_sort_file_size, 0, (gptr*) &max_system_variables.myisam_max_sort_file_size, 0,
GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, ~0L, 0, 1024*1024, 0}, GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, ~0L, 0, 1024*1024, 0},
{"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS,
"Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.",
(gptr*) &global_system_variables.myisam_repair_threads,
(gptr*) &max_system_variables.myisam_repair_threads, 0,
GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0},
{"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE, {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
"The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.", "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
(gptr*) &global_system_variables.myisam_sort_buff_size, (gptr*) &global_system_variables.myisam_sort_buff_size,
......
...@@ -167,6 +167,7 @@ sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count", ...@@ -167,6 +167,7 @@ sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
&max_write_lock_count); &max_write_lock_count);
sys_var_thd_ulonglong sys_myisam_max_extra_sort_file_size("myisam_max_extra_sort_file_size", &SV::myisam_max_extra_sort_file_size); sys_var_thd_ulonglong sys_myisam_max_extra_sort_file_size("myisam_max_extra_sort_file_size", &SV::myisam_max_extra_sort_file_size);
sys_var_thd_ulonglong sys_myisam_max_sort_file_size("myisam_max_sort_file_size", &SV::myisam_max_sort_file_size); sys_var_thd_ulonglong sys_myisam_max_sort_file_size("myisam_max_sort_file_size", &SV::myisam_max_sort_file_size);
sys_var_thd_ulong sys_myisam_repair_threads("myisam_repair_threads", &SV::myisam_repair_threads);
sys_var_thd_ulong sys_myisam_sort_buffer_size("myisam_sort_buffer_size", &SV::myisam_sort_buff_size); sys_var_thd_ulong sys_myisam_sort_buffer_size("myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
sys_var_thd_ulong sys_net_buffer_length("net_buffer_length", sys_var_thd_ulong sys_net_buffer_length("net_buffer_length",
&SV::net_buffer_length); &SV::net_buffer_length);
...@@ -342,6 +343,7 @@ sys_var *sys_variables[]= ...@@ -342,6 +343,7 @@ sys_var *sys_variables[]=
&sys_max_write_lock_count, &sys_max_write_lock_count,
&sys_myisam_max_extra_sort_file_size, &sys_myisam_max_extra_sort_file_size,
&sys_myisam_max_sort_file_size, &sys_myisam_max_sort_file_size,
&sys_myisam_repair_threads,
&sys_myisam_sort_buffer_size, &sys_myisam_sort_buffer_size,
&sys_net_buffer_length, &sys_net_buffer_length,
&sys_net_read_timeout, &sys_net_read_timeout,
...@@ -480,8 +482,9 @@ struct show_var_st init_vars[]= { ...@@ -480,8 +482,9 @@ struct show_var_st init_vars[]= {
{sys_myisam_max_extra_sort_file_size.name, {sys_myisam_max_extra_sort_file_size.name,
(char*) &sys_myisam_max_extra_sort_file_size, (char*) &sys_myisam_max_extra_sort_file_size,
SHOW_SYS}, SHOW_SYS},
{sys_myisam_max_sort_file_size.name, {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
(char*) &sys_myisam_max_sort_file_size, SHOW_SYS},
{sys_myisam_repair_threads.name, (char*) &sys_myisam_repair_threads,
SHOW_SYS}, SHOW_SYS},
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR}, {"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
{sys_myisam_sort_buffer_size.name, (char*) &sys_myisam_sort_buffer_size, SHOW_SYS}, {sys_myisam_sort_buffer_size.name, (char*) &sys_myisam_sort_buffer_size, SHOW_SYS},
......
...@@ -294,6 +294,7 @@ struct system_variables ...@@ -294,6 +294,7 @@ struct system_variables
ulong max_heap_table_size; ulong max_heap_table_size;
ulong max_sort_length; ulong max_sort_length;
ulong max_tmp_tables; ulong max_tmp_tables;
ulong myisam_repair_threads;
ulong myisam_sort_buff_size; ulong myisam_sort_buff_size;
ulong net_buffer_length; ulong net_buffer_length;
ulong net_interactive_timeout; ulong net_interactive_timeout;
......
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