Commit 52236ae1 authored by unknown's avatar unknown

Fixed Bug#2491, INSERT DELAYED causes binary log unusable by mysqlbinlog (replication is ok)

Setting insert delayed threads = 0 at mysql_init_command.


sql/mysql_priv.h:
  New session variable, max_insert_delayed_threads
sql/mysqld.cc:
  New session variable, max_insert_delayed_threads
sql/set_var.cc:
  New session variable, max_insert_delayed_threads
sql/sql_class.h:
  New session variable, max_insert_delayed_threads
sql/sql_insert.cc:
  New session variable, max_insert_delayed_threads
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent b6051940
...@@ -46,6 +46,7 @@ jani@rhols221.adsl.netsonic.fi ...@@ -46,6 +46,7 @@ jani@rhols221.adsl.netsonic.fi
jani@rhols221.arenanet.fi jani@rhols221.arenanet.fi
jani@ua126d19.elisa.omakaista.fi jani@ua126d19.elisa.omakaista.fi
jani@ua141d10.elisa.omakaista.fi jani@ua141d10.elisa.omakaista.fi
jani@ua72d24.elisa.omakaista.fi
jcole@abel.spaceapes.com jcole@abel.spaceapes.com
jcole@main.burghcom.com jcole@main.burghcom.com
jcole@mugatu.spaceapes.com jcole@mugatu.spaceapes.com
......
...@@ -480,7 +480,7 @@ static void die(const char* fmt, ...) ...@@ -480,7 +480,7 @@ static void die(const char* fmt, ...)
static void print_version() static void print_version()
{ {
printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
} }
...@@ -562,9 +562,12 @@ static int parse_args(int *argc, char*** argv) ...@@ -562,9 +562,12 @@ static int parse_args(int *argc, char*** argv)
static MYSQL* safe_connect() static MYSQL* safe_connect()
{ {
MYSQL *local_mysql = mysql_init(NULL); MYSQL *local_mysql = mysql_init(NULL);
if(!local_mysql) if(!local_mysql)
die("Failed on mysql_init"); die("Failed on mysql_init");
mysql_options(local_mysql, MYSQL_INIT_COMMAND,
"/*!32210 SET @@session.max_insert_delayed_threads=0*/");
if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0))
die("failed on connect: %s", mysql_error(local_mysql)); die("failed on connect: %s", mysql_error(local_mysql));
......
...@@ -688,7 +688,7 @@ extern ulong ha_read_first_count, ha_read_last_count; ...@@ -688,7 +688,7 @@ extern ulong ha_read_first_count, ha_read_last_count;
extern ulong ha_read_rnd_count, ha_read_rnd_next_count; extern ulong ha_read_rnd_count, ha_read_rnd_next_count;
extern ulong ha_commit_count, ha_rollback_count,table_cache_size; extern ulong ha_commit_count, ha_rollback_count,table_cache_size;
extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong max_connections,max_connect_errors, connect_timeout;
extern ulong max_insert_delayed_threads, max_user_connections; extern ulong max_user_connections;
extern ulong long_query_count, what_to_log,flush_time,opt_sql_mode; extern ulong long_query_count, what_to_log,flush_time,opt_sql_mode;
extern ulong query_buff_size, thread_stack,thread_stack_min; extern ulong query_buff_size, thread_stack,thread_stack_min;
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
......
...@@ -399,7 +399,7 @@ ulong select_range_check_count, select_range_count, select_scan_count; ...@@ -399,7 +399,7 @@ ulong select_range_check_count, select_range_count, select_scan_count;
ulong select_full_range_join_count,select_full_join_count; ulong select_full_range_join_count,select_full_join_count;
ulong specialflag=0,opened_tables=0,created_tmp_tables=0, ulong specialflag=0,opened_tables=0,created_tmp_tables=0,
created_tmp_disk_tables=0; created_tmp_disk_tables=0;
ulong max_connections,max_insert_delayed_threads,max_used_connections, ulong max_connections, max_used_connections,
max_connect_errors, max_user_connections = 0; max_connect_errors, max_user_connections = 0;
ulong thread_id=1L,current_pid; ulong thread_id=1L,current_pid;
ulong slow_launch_threads = 0; ulong slow_launch_threads = 0;
...@@ -1726,7 +1726,8 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) ...@@ -1726,7 +1726,8 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
This should actually be '+ max_number_of_slaves' instead of +10, This should actually be '+ max_number_of_slaves' instead of +10,
but the +10 should be quite safe. but the +10 should be quite safe.
*/ */
init_thr_alarm(max_connections+max_insert_delayed_threads+10); init_thr_alarm(max_connections +
global_system_variables.max_insert_delayed_threads + 10);
#if SIGINT != THR_KILL_SIGNAL #if SIGINT != THR_KILL_SIGNAL
if (test_flags & TEST_SIGINT) if (test_flags & TEST_SIGINT)
{ {
...@@ -3896,7 +3897,8 @@ The minimum value for this variable is 4096.", ...@@ -3896,7 +3897,8 @@ The minimum value for this variable is 4096.",
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0}, REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0},
{"max_delayed_threads", OPT_MAX_DELAYED_THREADS, {"max_delayed_threads", OPT_MAX_DELAYED_THREADS,
"Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.", "Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.",
(gptr*) &max_insert_delayed_threads, (gptr*) &max_insert_delayed_threads, (gptr*) &global_system_variables.max_insert_delayed_threads,
(gptr*) &max_system_variables.max_insert_delayed_threads,
0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0}, 0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0},
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
"Don't allow creation of heap tables bigger than this.", "Don't allow creation of heap tables bigger than this.",
......
...@@ -155,8 +155,10 @@ sys_var_long_ptr sys_max_connections("max_connections", ...@@ -155,8 +155,10 @@ sys_var_long_ptr sys_max_connections("max_connections",
fix_max_connections); fix_max_connections);
sys_var_long_ptr sys_max_connect_errors("max_connect_errors", sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
&max_connect_errors); &max_connect_errors);
sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads", sys_var_thd_ulong sys_max_insert_delayed_threads("max_insert_delayed_threads",
&max_insert_delayed_threads, &SV::max_insert_delayed_threads);
sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads",
&SV::max_insert_delayed_threads,
fix_max_connections); fix_max_connections);
sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size", sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size",
&SV::max_heap_table_size); &SV::max_heap_table_size);
...@@ -381,6 +383,7 @@ sys_var *sys_variables[]= ...@@ -381,6 +383,7 @@ sys_var *sys_variables[]=
&sys_max_connect_errors, &sys_max_connect_errors,
&sys_max_connections, &sys_max_connections,
&sys_max_delayed_threads, &sys_max_delayed_threads,
&sys_max_insert_delayed_threads,
&sys_max_heap_table_size, &sys_max_heap_table_size,
&sys_max_join_size, &sys_max_join_size,
&sys_max_relay_log_size, &sys_max_relay_log_size,
...@@ -771,7 +774,8 @@ static void fix_max_relay_log_size(THD *thd, enum_var_type type) ...@@ -771,7 +774,8 @@ static void fix_max_relay_log_size(THD *thd, enum_var_type type)
static void fix_max_connections(THD *thd, enum_var_type type) static void fix_max_connections(THD *thd, enum_var_type type)
{ {
resize_thr_alarm(max_connections + max_insert_delayed_threads + 10); resize_thr_alarm(max_connections +
global_system_variables.max_insert_delayed_threads + 10);
} }
......
...@@ -310,6 +310,7 @@ struct system_variables ...@@ -310,6 +310,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 max_insert_delayed_threads;
ulong myisam_repair_threads; ulong myisam_repair_threads;
ulong myisam_sort_buff_size; ulong myisam_sort_buff_size;
ulong net_buffer_length; ulong net_buffer_length;
......
...@@ -139,7 +139,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields, ...@@ -139,7 +139,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
*/ */
if ((lock_type == TL_WRITE_DELAYED && if ((lock_type == TL_WRITE_DELAYED &&
((specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) || ((specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) ||
thd->slave_thread || !max_insert_delayed_threads)) || thd->slave_thread || !thd->variables.max_insert_delayed_threads)) ||
(lock_type == TL_WRITE_CONCURRENT_INSERT && duplic == DUP_REPLACE)) (lock_type == TL_WRITE_CONCURRENT_INSERT && duplic == DUP_REPLACE))
lock_type=TL_WRITE; lock_type=TL_WRITE;
...@@ -655,7 +655,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) ...@@ -655,7 +655,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
if (!(tmp=find_handler(thd,table_list))) if (!(tmp=find_handler(thd,table_list)))
{ {
/* Don't create more than max_insert_delayed_threads */ /* Don't create more than max_insert_delayed_threads */
if (delayed_insert_threads >= max_insert_delayed_threads) if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
DBUG_RETURN(0); DBUG_RETURN(0);
thd->proc_info="Creating delayed handler"; thd->proc_info="Creating delayed handler";
pthread_mutex_lock(&LOCK_delayed_create); pthread_mutex_lock(&LOCK_delayed_create);
......
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