mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 21:25:36 +02:00
An attempt to fix a sporadic valgrind memory leak in Event Scheduler:
streamline the event worker thread work flow and try to eliminate possibilities for memory corruptions that might have been lurking in previous (complicated) code. This patch: * removes Event_job_data::compile that was never used * cleans up Event_job_data::execute to minimize juggling with thread context and eliminate unneded code paths * Implements Security_context::change/restore_security_context to be able to re-use these methods in all stored programs This is to maybe fix Bug#27733 "Valgrind failures in remove_table_from_cache". Review comments applied. sql/event_data_objects.cc: Remove Event_job_data::compile, which was never used without Event_job_data::execute(). Merge the implementation of compile() with Event_job_data::execute(). Reuse existing functions to prepare the event worker thread for execution instead of some previously copy-pasted code. Do not change and restore the current database inside Event_job_data::execute(), just set the current database in the thread, that is enough to parse and execute an event. sql/event_data_objects.h: Update declarations. sql/event_scheduler.cc: Allocate Event_job_data on stack. sql/item_func.cc: Update to match the new declaration of restore_security_context() sql/sp_head.cc: Update to match the new declaration of change/restore_security_context() sql/sql_class.cc: Move change/restore_security_context to class Security_context. Add more comments. sql/sql_class.h: Make change/restore_security_context methods of Security_context. That allows us to reuse them in Event Scheduler (instead of a copy-paste presently used there). sql/sql_trigger.cc: Update to match the new declaration of change/restore_security_context()
This commit is contained in:
parent
d4744eb9dd
commit
c1b6e128cc
8 changed files with 301 additions and 364 deletions
|
|
@ -277,8 +277,7 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
|
|||
{
|
||||
/* needs to be first for thread_stack */
|
||||
char my_stack;
|
||||
int ret;
|
||||
Event_job_data *job_data= NULL;
|
||||
Event_job_data job_data;
|
||||
bool res;
|
||||
|
||||
thd->thread_stack= &my_stack; // remember where our stack is
|
||||
|
|
@ -291,60 +290,43 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
|
|||
if (res)
|
||||
goto end;
|
||||
|
||||
if (!(job_data= new Event_job_data()))
|
||||
goto end;
|
||||
else if ((ret= db_repository->
|
||||
load_named_event(thd, event->dbname, event->name, job_data)))
|
||||
if ((res= db_repository->load_named_event(thd, event->dbname, event->name,
|
||||
&job_data)))
|
||||
{
|
||||
DBUG_PRINT("error", ("Got %d from load_named_event", ret));
|
||||
DBUG_PRINT("error", ("Got error from load_named_event"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
sql_print_information("Event Scheduler: "
|
||||
"[%s.%s of %s] executing in thread %lu. ",
|
||||
job_data->dbname.str, job_data->name.str,
|
||||
job_data->definer.str, thd->thread_id);
|
||||
"[%s].[%s.%s] started in thread %lu.",
|
||||
job_data.definer.str,
|
||||
job_data.dbname.str, job_data.name.str,
|
||||
thd->thread_id);
|
||||
|
||||
thd->enable_slow_log= TRUE;
|
||||
|
||||
ret= job_data->execute(thd, event->dropped);
|
||||
res= job_data.execute(thd, event->dropped);
|
||||
|
||||
print_warnings(thd, job_data);
|
||||
print_warnings(thd, &job_data);
|
||||
|
||||
switch (ret) {
|
||||
case 0:
|
||||
sql_print_information("Event Scheduler: "
|
||||
"[%s].[%s.%s] executed successfully in thread %lu.",
|
||||
job_data->definer.str,
|
||||
job_data->dbname.str, job_data->name.str,
|
||||
thd->thread_id);
|
||||
break;
|
||||
case EVEX_COMPILE_ERROR:
|
||||
sql_print_information("Event Scheduler: "
|
||||
"[%s].[%s.%s] event compilation failed.",
|
||||
job_data->definer.str,
|
||||
job_data->dbname.str, job_data->name.str);
|
||||
break;
|
||||
default:
|
||||
if (res)
|
||||
sql_print_information("Event Scheduler: "
|
||||
"[%s].[%s.%s] event execution failed.",
|
||||
job_data->definer.str,
|
||||
job_data->dbname.str, job_data->name.str);
|
||||
break;
|
||||
}
|
||||
job_data.definer.str,
|
||||
job_data.dbname.str, job_data.name.str);
|
||||
else
|
||||
sql_print_information("Event Scheduler: "
|
||||
"[%s].[%s.%s] executed successfully in thread %lu.",
|
||||
job_data.definer.str,
|
||||
job_data.dbname.str, job_data.name.str,
|
||||
thd->thread_id);
|
||||
|
||||
end:
|
||||
delete job_data;
|
||||
|
||||
DBUG_PRINT("info", ("Done with Event %s.%s", event->dbname.str,
|
||||
event->name.str));
|
||||
|
||||
delete event;
|
||||
deinit_event_thread(thd);
|
||||
/*
|
||||
Do not pthread_exit since we want local destructors for stack objects
|
||||
to be invoked.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue