Commit f3a1967b authored by unknown's avatar unknown

parallel-repair available in mysqld

parent 97946e16
......@@ -2246,7 +2246,17 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
else
rec_length=share->base.pack_reclength;
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));
del=info->state->del;
......
......@@ -579,10 +579,24 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
{
local_testflag|= T_STATISTICS;
param.testflag|= T_STATISTICS; // We get this for free
thd->proc_info="Repair by sorting";
statistics_done=1;
error = mi_repair_by_sort(&param, file, fixed_name,
param.testflag & T_QUICK);
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,
param.testflag & T_QUICK);
}
}
else
{
......
......@@ -3145,7 +3145,7 @@ enum options {
OPT_SORT_BUFFER, OPT_TABLE_CACHE,
OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
OPT_WAIT_TIMEOUT,
OPT_WAIT_TIMEOUT, OPT_MYISAM_REPAIR_THREADS,
OPT_INNODB_MIRRORED_LOG_GROUPS,
OPT_INNODB_LOG_FILES_IN_GROUP,
OPT_INNODB_LOG_FILE_SIZE,
......@@ -3839,13 +3839,18 @@ replicating a LOAD DATA INFILE command",
(gptr*) &global_system_variables.myisam_max_sort_file_size,
(gptr*) &max_system_variables.myisam_max_sort_file_size, 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,
"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*) &max_system_variables.myisam_sort_buff_size, 0,
GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"Buffer length for TCP/IP and socket communication.",
"Buffer length for TCP/IP and socket communication.",
(gptr*) &global_system_variables.net_buffer_length,
(gptr*) &max_system_variables.net_buffer_length, 0, GET_ULONG,
REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
......
......@@ -167,6 +167,7 @@ sys_var_long_ptr sys_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_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_net_buffer_length("net_buffer_length",
&SV::net_buffer_length);
......@@ -342,6 +343,7 @@ sys_var *sys_variables[]=
&sys_max_write_lock_count,
&sys_myisam_max_extra_sort_file_size,
&sys_myisam_max_sort_file_size,
&sys_myisam_repair_threads,
&sys_myisam_sort_buffer_size,
&sys_net_buffer_length,
&sys_net_read_timeout,
......@@ -475,13 +477,14 @@ struct show_var_st init_vars[]= {
{sys_max_join_size.name, (char*) &sys_max_join_size, SHOW_SYS},
{sys_max_sort_length.name, (char*) &sys_max_sort_length, SHOW_SYS},
{sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
{sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
{sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
{sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
{sys_myisam_max_extra_sort_file_size.name,
(char*) &sys_myisam_max_extra_sort_file_size,
SHOW_SYS},
{sys_myisam_max_sort_file_size.name,
(char*) &sys_myisam_max_sort_file_size,
{sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
SHOW_SYS},
{sys_myisam_repair_threads.name, (char*) &sys_myisam_repair_threads,
SHOW_SYS},
{"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},
......
......@@ -294,6 +294,7 @@ struct system_variables
ulong max_heap_table_size;
ulong max_sort_length;
ulong max_tmp_tables;
ulong myisam_repair_threads;
ulong myisam_sort_buff_size;
ulong net_buffer_length;
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