Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b4bf7dd3
Commit
b4bf7dd3
authored
Jul 24, 2009
by
Konstantin Osipov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review for Bug#43587 Putting event_scheduler=1 in init SQL file crashes
mysqld
parent
c24cccab
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
27 deletions
+60
-27
mysql-test/std_data/init_file.dat
mysql-test/std_data/init_file.dat
+6
-0
sql/event_scheduler.cc
sql/event_scheduler.cc
+3
-0
sql/events.cc
sql/events.cc
+26
-21
sql/mysql_priv.h
sql/mysql_priv.h
+1
-0
sql/mysqld.cc
sql/mysqld.cc
+22
-5
sql/sql_parse.cc
sql/sql_parse.cc
+2
-1
No files found.
mysql-test/std_data/init_file.dat
View file @
b4bf7dd3
...
@@ -35,4 +35,10 @@ CREATE DATABASE IF NOT EXISTS init_file;
...
@@ -35,4 +35,10 @@ CREATE DATABASE IF NOT EXISTS init_file;
CREATE TABLE IF NOT EXISTS init_file.startup ( startdate DATETIME );
CREATE TABLE IF NOT EXISTS init_file.startup ( startdate DATETIME );
INSERT INTO init_file.startup VALUES ( NOW() );
INSERT INTO init_file.startup VALUES ( NOW() );
#
# Bug#43587 "Putting event_scheduler=1 in init SQL file crashes mysqld"
# Check that putting event_scheduler=1 to init file doesn't lead to
# crashes.
#
SET GLOBAL event_scheduler=1;
sql/event_scheduler.cc
View file @
b4bf7dd3
...
@@ -158,6 +158,7 @@ deinit_event_thread(THD *thd)
...
@@ -158,6 +158,7 @@ deinit_event_thread(THD *thd)
thread_count
--
;
thread_count
--
;
thread_running
--
;
thread_running
--
;
delete
thd
;
delete
thd
;
pthread_cond_broadcast
(
&
COND_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
}
}
...
@@ -418,6 +419,7 @@ Event_scheduler::start()
...
@@ -418,6 +419,7 @@ Event_scheduler::start()
thread_count
--
;
thread_count
--
;
thread_running
--
;
thread_running
--
;
delete
new_thd
;
delete
new_thd
;
pthread_cond_broadcast
(
&
COND_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
}
}
end:
end:
...
@@ -550,6 +552,7 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
...
@@ -550,6 +552,7 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
thread_count
--
;
thread_count
--
;
thread_running
--
;
thread_running
--
;
delete
new_thd
;
delete
new_thd
;
pthread_cond_broadcast
(
&
COND_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
pthread_mutex_unlock
(
&
LOCK_thread_count
);
}
}
delete
event_name
;
delete
event_name
;
...
...
sql/events.cc
View file @
b4bf7dd3
...
@@ -852,22 +852,23 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
...
@@ -852,22 +852,23 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
}
}
/*
/*
*
Inits the scheduler's structures.
Init
ialize
s the scheduler's structures.
SYNOPSIS
@param opt_noacl_or_bootstrap
Events::init()
TRUE if there is --skip-grant-tables or --bootstrap
option. In that case we disable the event scheduler.
NOTES
@note This function is not synchronized.
This function is not synchronized.
RETURN VALUE
@retval FALSE Perhaps there was an error, and the event scheduler
FALSE OK
is disabled. But the error is not fatal and the
TRUE Error in case the scheduler can't start
server start up can continue.
@retval TRUE Fatal error. Startup must terminate (call unireg_abort()).
*/
*/
bool
bool
Events
::
init
(
my_bool
opt_noacl
)
Events
::
init
(
my_bool
opt_noacl
_or_bootstrap
)
{
{
THD
*
thd
;
THD
*
thd
;
...
@@ -875,11 +876,6 @@ Events::init(my_bool opt_noacl)
...
@@ -875,11 +876,6 @@ Events::init(my_bool opt_noacl)
DBUG_ENTER
(
"Events::init"
);
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 */
/* We need a temporary THD during boot */
if
(
!
(
thd
=
new
THD
()))
if
(
!
(
thd
=
new
THD
()))
{
{
...
@@ -908,13 +904,21 @@ Events::init(my_bool opt_noacl)
...
@@ -908,13 +904,21 @@ Events::init(my_bool opt_noacl)
/*
/*
Since we allow event DDL even if the scheduler is disabled,
Since we allow event DDL even if the scheduler is disabled,
check the system tables, as we might need them.
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
))
{
if
(
!
opt_noacl_or_bootstrap
)
{
{
sql_print_error
(
"Event Scheduler: An error occurred when initializing "
sql_print_error
(
"Event Scheduler: An error occurred when initializing "
"system tables.%s"
,
"system tables.%s"
,
opt_event_scheduler
==
EVENTS_DISABLED
?
opt_event_scheduler
==
EVENTS_DISABLED
?
""
:
" Disabling the Event Scheduler."
);
""
:
" Disabling the Event Scheduler."
);
}
/* Disable the scheduler since the system tables are not up to date */
/* Disable the scheduler since the system tables are not up to date */
opt_event_scheduler
=
EVENTS_DISABLED
;
opt_event_scheduler
=
EVENTS_DISABLED
;
...
@@ -924,7 +928,8 @@ Events::init(my_bool opt_noacl)
...
@@ -924,7 +928,8 @@ Events::init(my_bool opt_noacl)
/*
/*
Was disabled explicitly from the command line, or because we're running
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
)
if
(
opt_event_scheduler
==
Events
::
EVENTS_DISABLED
)
goto
end
;
goto
end
;
...
...
sql/mysql_priv.h
View file @
b4bf7dd3
...
@@ -1976,6 +1976,7 @@ extern bool opt_disable_networking, opt_skip_show_db;
...
@@ -1976,6 +1976,7 @@ extern bool opt_disable_networking, opt_skip_show_db;
extern
bool
opt_ignore_builtin_innodb
;
extern
bool
opt_ignore_builtin_innodb
;
extern
my_bool
opt_character_set_client_handshake
;
extern
my_bool
opt_character_set_client_handshake
;
extern
bool
volatile
abort_loop
,
shutdown_in_progress
;
extern
bool
volatile
abort_loop
,
shutdown_in_progress
;
extern
bool
in_bootstrap
;
extern
uint
volatile
thread_count
,
thread_running
,
global_read_lock
;
extern
uint
volatile
thread_count
,
thread_running
,
global_read_lock
;
extern
uint
connection_count
;
extern
uint
connection_count
;
extern
my_bool
opt_sql_bin_update
,
opt_safe_user_create
,
opt_no_mix_types
;
extern
my_bool
opt_sql_bin_update
,
opt_safe_user_create
,
opt_no_mix_types
;
...
...
sql/mysqld.cc
View file @
b4bf7dd3
...
@@ -416,6 +416,21 @@ my_bool locked_in_memory;
...
@@ -416,6 +416,21 @@ my_bool locked_in_memory;
bool
opt_using_transactions
;
bool
opt_using_transactions
;
bool
volatile
abort_loop
;
bool
volatile
abort_loop
;
bool
volatile
shutdown_in_progress
;
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
@brief 'grant_option' is used to indicate if privileges needs
to be checked, in which case the lock, LOCK_grant, is used
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.");
...
@@ -4426,6 +4441,11 @@ we force server id to 2, but this MySQL server will not act as a slave.");
unireg_abort
(
1
);
unireg_abort
(
1
);
}
}
execute_ddl_log_recovery
();
if
(
Events
::
init
(
opt_noacl
||
opt_bootstrap
))
unireg_abort
(
1
);
if
(
opt_bootstrap
)
if
(
opt_bootstrap
)
{
{
select_thread_in_use
=
0
;
// Allow 'kill' to work
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.");
...
@@ -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
))
if
(
read_init_file
(
opt_init_file
))
unireg_abort
(
1
);
unireg_abort
(
1
);
}
}
execute_ddl_log_recovery
();
create_shutdown_thread
();
create_shutdown_thread
();
start_handle_manager
();
start_handle_manager
();
if
(
Events
::
init
(
opt_noacl
))
unireg_abort
(
1
);
sql_print_information
(
ER
(
ER_STARTUP
),
my_progname
,
server_version
,
sql_print_information
(
ER
(
ER_STARTUP
),
my_progname
,
server_version
,
((
unix_sock
==
INVALID_SOCKET
)
?
(
char
*
)
""
((
unix_sock
==
INVALID_SOCKET
)
?
(
char
*
)
""
:
mysqld_unix_port
),
:
mysqld_unix_port
),
...
@@ -4726,6 +4742,7 @@ static void bootstrap(FILE *file)
...
@@ -4726,6 +4742,7 @@ static void bootstrap(FILE *file)
thd
->
security_ctx
->
master_access
=
~
(
ulong
)
0
;
thd
->
security_ctx
->
master_access
=
~
(
ulong
)
0
;
thd
->
thread_id
=
thd
->
variables
.
pseudo_thread_id
=
thread_id
++
;
thd
->
thread_id
=
thd
->
variables
.
pseudo_thread_id
=
thread_id
++
;
thread_count
++
;
thread_count
++
;
in_bootstrap
=
TRUE
;
bootstrap_file
=
file
;
bootstrap_file
=
file
;
#ifndef EMBEDDED_LIBRARY // TODO: Enable this
#ifndef EMBEDDED_LIBRARY // TODO: Enable this
...
@@ -4738,7 +4755,7 @@ static void bootstrap(FILE *file)
...
@@ -4738,7 +4755,7 @@ static void bootstrap(FILE *file)
}
}
/* Wait for thread to die */
/* Wait for thread to die */
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
while
(
thread_count
)
while
(
in_bootstrap
)
{
{
(
void
)
pthread_cond_wait
(
&
COND_thread_count
,
&
LOCK_thread_count
);
(
void
)
pthread_cond_wait
(
&
COND_thread_count
,
&
LOCK_thread_count
);
DBUG_PRINT
(
"quit"
,(
"One thread died (count=%u)"
,
thread_count
));
DBUG_PRINT
(
"quit"
,(
"One thread died (count=%u)"
,
thread_count
));
...
...
sql/sql_parse.cc
View file @
b4bf7dd3
...
@@ -533,8 +533,9 @@ pthread_handler_t handle_bootstrap(void *arg)
...
@@ -533,8 +533,9 @@ pthread_handler_t handle_bootstrap(void *arg)
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
thread_count
--
;
thread_count
--
;
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
)
;
in_bootstrap
=
FALSE
;
(
void
)
pthread_cond_broadcast
(
&
COND_thread_count
);
(
void
)
pthread_cond_broadcast
(
&
COND_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
my_thread_end
();
my_thread_end
();
pthread_exit
(
0
);
pthread_exit
(
0
);
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment