diff options
| author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-07-24 15:45:42 -0300 |
|---|---|---|
| committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-07-24 15:45:42 -0300 |
| commit | 8ec2f3d0d1943a282648bd0fe708539a539b18cc (patch) | |
| tree | 97c922ce909fe27e454cb40b715ce727b941f8f3 /sql/mysqld.cc | |
| parent | 2bc6b6a80099ddb5b57e3d3c8be120e6596daa08 (diff) | |
| parent | b4bf7dd31e39cd98f5794e4d7ef71cf03d0669dd (diff) | |
| download | mariadb-git-8ec2f3d0d1943a282648bd0fe708539a539b18cc.tar.gz | |
Bug#43587: Putting event_scheduler=1 in init SQL file crashes
mysqld
The problem was that enabling the event scheduler inside a init
file caused the server to crash upon start-up. The crash occurred
because the event scheduler wasn't being initialized before the
commands in the init-file are processed.
The solution is to initialize the event scheduler before the init
file is read. The patch also disables the event scheduler during
bootstrap and makes the bootstrap operation robust in the
presence of background threads.
mysql-test/std_data/init_file.dat:
Add test case for Bug#43587
sql/event_scheduler.cc:
Signal that the thread_count has been decremented.
sql/events.cc:
Disable the event scheduler during bootstrap.
sql/mysql_priv.h:
Export variable.
sql/mysqld.cc:
Initialize the event scheduler before commands are executed.
sql/sql_parse.cc:
Signal that the bootstrap thread is done.
Diffstat (limited to 'sql/mysqld.cc')
| -rw-r--r-- | sql/mysqld.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7e61527a19b..d76a897519c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -416,6 +416,21 @@ my_bool locked_in_memory; bool opt_using_transactions; bool volatile abort_loop; bool volatile shutdown_in_progress; +/* + True if the bootstrap thread is running. Protected by LOCK_thread_count, + just like thread_count. + Used in bootstrap() function to determine if the bootstrap thread + has completed. Note, that we can't use 'thread_count' instead, + since in 5.1, in presence of the Event Scheduler, there may be + event threads running in parallel, so it's impossible to know + what value of 'thread_count' is a sign of completion of the + bootstrap thread. + + At the same time, we can't start the event scheduler after + bootstrap either, since we want to be able to process event-related + SQL commands in the init file and in --bootstrap mode. +*/ +bool in_bootstrap= FALSE; /** @brief 'grant_option' is used to indicate if privileges needs to be checked, in which case the lock, LOCK_grant, is used @@ -4426,6 +4441,11 @@ we force server id to 2, but this MySQL server will not act as a slave."); unireg_abort(1); } + execute_ddl_log_recovery(); + + if (Events::init(opt_noacl || opt_bootstrap)) + unireg_abort(1); + if (opt_bootstrap) { select_thread_in_use= 0; // Allow 'kill' to work @@ -4437,14 +4457,10 @@ we force server id to 2, but this MySQL server will not act as a slave."); if (read_init_file(opt_init_file)) unireg_abort(1); } - execute_ddl_log_recovery(); create_shutdown_thread(); start_handle_manager(); - if (Events::init(opt_noacl)) - unireg_abort(1); - sql_print_information(ER(ER_STARTUP),my_progname,server_version, ((unix_sock == INVALID_SOCKET) ? (char*) "" : mysqld_unix_port), @@ -4726,6 +4742,7 @@ static void bootstrap(FILE *file) thd->security_ctx->master_access= ~(ulong)0; thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; thread_count++; + in_bootstrap= TRUE; bootstrap_file=file; #ifndef EMBEDDED_LIBRARY // TODO: Enable this @@ -4738,7 +4755,7 @@ static void bootstrap(FILE *file) } /* Wait for thread to die */ (void) pthread_mutex_lock(&LOCK_thread_count); - while (thread_count) + while (in_bootstrap) { (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count); DBUG_PRINT("quit",("One thread died (count=%u)",thread_count)); |
