summaryrefslogtreecommitdiff
path: root/sql/events.cc
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-07-24 15:45:42 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-07-24 15:45:42 -0300
commit97ff334b371331e34ec741a021d8aa0b5449480e (patch)
tree97c922ce909fe27e454cb40b715ce727b941f8f3 /sql/events.cc
parent9c72a7bfeac53a3402621bc451f25c81d0713811 (diff)
parent31997022d79f55922e4915fe649619f2dcc1ab40 (diff)
downloadmariadb-git-97ff334b371331e34ec741a021d8aa0b5449480e.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.
Diffstat (limited to 'sql/events.cc')
-rw-r--r--sql/events.cc49
1 files changed, 26 insertions, 23 deletions
diff --git a/sql/events.cc b/sql/events.cc
index ea935e67bd3..10edfff2402 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -852,22 +852,23 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
}
-/*
- Inits the scheduler's structures.
+/**
+ Initializes the scheduler's structures.
- SYNOPSIS
- Events::init()
+ @param opt_noacl_or_bootstrap
+ TRUE if there is --skip-grant-tables or --bootstrap
+ option. In that case we disable the event scheduler.
- NOTES
- This function is not synchronized.
+ @note This function is not synchronized.
- RETURN VALUE
- FALSE OK
- TRUE Error in case the scheduler can't start
+ @retval FALSE Perhaps there was an error, and the event scheduler
+ is disabled. But the error is not fatal and the
+ server start up can continue.
+ @retval TRUE Fatal error. Startup must terminate (call unireg_abort()).
*/
bool
-Events::init(my_bool opt_noacl)
+Events::init(my_bool opt_noacl_or_bootstrap)
{
THD *thd;
@@ -875,11 +876,6 @@ Events::init(my_bool opt_noacl)
DBUG_ENTER("Events::init");
- /* Disable the scheduler if running with --skip-grant-tables */
- if (opt_noacl)
- opt_event_scheduler= EVENTS_DISABLED;
-
-
/* We need a temporary THD during boot */
if (!(thd= new THD()))
{
@@ -908,23 +904,30 @@ Events::init(my_bool opt_noacl)
/*
Since we allow event DDL even if the scheduler is disabled,
check the system tables, as we might need them.
+
+ If run with --skip-grant-tables or --bootstrap, don't try to do the
+ check of system tables and don't complain: in these modes the tables
+ are most likely not there and we're going to disable the event
+ scheduler anyway.
*/
- if (Event_db_repository::check_system_tables(thd))
+ if (opt_noacl_or_bootstrap || Event_db_repository::check_system_tables(thd))
{
- sql_print_error("Event Scheduler: An error occurred when initializing "
- "system tables.%s",
- opt_event_scheduler == EVENTS_DISABLED ?
- "" : " Disabling the Event Scheduler.");
+ if (! opt_noacl_or_bootstrap)
+ {
+ sql_print_error("Event Scheduler: An error occurred when initializing "
+ "system tables. Disabling the Event Scheduler.");
+ check_system_tables_error= TRUE;
+ }
/* Disable the scheduler since the system tables are not up to date */
opt_event_scheduler= EVENTS_DISABLED;
- check_system_tables_error= TRUE;
goto end;
}
/*
Was disabled explicitly from the command line, or because we're running
- with --skip-grant-tables, or because we have no system tables.
+ with --skip-grant-tables, or --bootstrap, or because we have no system
+ tables.
*/
if (opt_event_scheduler == Events::EVENTS_DISABLED)
goto end;
@@ -941,7 +944,7 @@ Events::init(my_bool opt_noacl)
}
if (event_queue->init_queue(thd) || load_events_from_db(thd) ||
- opt_event_scheduler == EVENTS_ON && scheduler->start())
+ (opt_event_scheduler == EVENTS_ON && scheduler->start()))
{
sql_print_error("Event Scheduler: Error while loading from disk.");
res= TRUE; /* fatal error: request unireg_abort */