mirror of
https://github.com/MariaDB/server.git
synced 2026-05-07 23:54:31 +02:00
mysql-5.5.34 merge
(some patches reverted, test case added)
This commit is contained in:
commit
fa3f8a18b2
91 changed files with 951 additions and 632 deletions
|
|
@ -241,6 +241,12 @@ event_scheduler_thread(void *arg)
|
|||
my_free(arg);
|
||||
if (!res)
|
||||
scheduler->run(thd);
|
||||
else
|
||||
{
|
||||
thd->proc_info= "Clearing";
|
||||
net_end(&thd->net);
|
||||
delete thd;
|
||||
}
|
||||
|
||||
DBUG_LEAVE; // Against gcc warnings
|
||||
my_thread_end();
|
||||
|
|
@ -368,26 +374,26 @@ Event_scheduler::~Event_scheduler()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
Starts the scheduler (again). Creates a new THD and passes it to
|
||||
a forked thread. Does not wait for acknowledgement from the new
|
||||
thread that it has started. Asynchronous starting. Most of the
|
||||
needed initializations are done in the current thread to minimize
|
||||
the chance of failure in the spawned thread.
|
||||
|
||||
SYNOPSIS
|
||||
Event_scheduler::start()
|
||||
@param[out] err_no - errno indicating type of error which caused
|
||||
failure to start scheduler thread.
|
||||
|
||||
RETURN VALUE
|
||||
FALSE OK
|
||||
TRUE Error (not reported)
|
||||
@return
|
||||
@retval false Success.
|
||||
@retval true Error.
|
||||
*/
|
||||
|
||||
bool
|
||||
Event_scheduler::start()
|
||||
Event_scheduler::start(int *err_no)
|
||||
{
|
||||
THD *new_thd= NULL;
|
||||
bool ret= FALSE;
|
||||
bool ret= false;
|
||||
pthread_t th;
|
||||
struct scheduler_param *scheduler_param_value;
|
||||
DBUG_ENTER("Event_scheduler::start");
|
||||
|
|
@ -400,7 +406,7 @@ Event_scheduler::start()
|
|||
if (!(new_thd= new THD))
|
||||
{
|
||||
sql_print_error("Event Scheduler: Cannot initialize the scheduler thread");
|
||||
ret= TRUE;
|
||||
ret= true;
|
||||
goto end;
|
||||
}
|
||||
pre_init_event_thread(new_thd);
|
||||
|
|
@ -423,28 +429,30 @@ Event_scheduler::start()
|
|||
DBUG_PRINT("info", ("Setting state go RUNNING"));
|
||||
state= RUNNING;
|
||||
DBUG_PRINT("info", ("Forking new thread for scheduler. THD: 0x%lx", (long) new_thd));
|
||||
if (mysql_thread_create(key_thread_event_scheduler,
|
||||
&th, &connection_attrib, event_scheduler_thread,
|
||||
(void*)scheduler_param_value))
|
||||
if ((*err_no= mysql_thread_create(key_thread_event_scheduler,
|
||||
&th, &connection_attrib,
|
||||
event_scheduler_thread,
|
||||
(void*)scheduler_param_value)))
|
||||
{
|
||||
DBUG_PRINT("error", ("cannot create a new thread"));
|
||||
state= INITIALIZED;
|
||||
scheduler_thd= NULL;
|
||||
ret= TRUE;
|
||||
sql_print_error("Event scheduler: Failed to start scheduler,"
|
||||
" Can not create thread for event scheduler (errno=%d)",
|
||||
*err_no);
|
||||
|
||||
new_thd->proc_info= "Clearing";
|
||||
DBUG_ASSERT(new_thd->net.buff != 0);
|
||||
net_end(&new_thd->net);
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
dec_thread_running();
|
||||
|
||||
state= INITIALIZED;
|
||||
scheduler_thd= NULL;
|
||||
delete new_thd;
|
||||
mysql_cond_broadcast(&COND_thread_count);
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
delete scheduler_param_value;
|
||||
ret= true;
|
||||
}
|
||||
|
||||
end:
|
||||
UNLOCK_DATA();
|
||||
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +563,20 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
|
|||
if ((res= mysql_thread_create(key_thread_event_worker,
|
||||
&th, &connection_attrib, event_worker_thread,
|
||||
event_name)))
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_global_system_variables);
|
||||
Events::opt_event_scheduler= Events::EVENTS_OFF;
|
||||
mysql_mutex_unlock(&LOCK_global_system_variables);
|
||||
|
||||
sql_print_error("Event_scheduler::execute_top: Can not create event worker"
|
||||
" thread (errno=%d). Stopping event scheduler", res);
|
||||
|
||||
new_thd->proc_info= "Clearing";
|
||||
DBUG_ASSERT(new_thd->net.buff != 0);
|
||||
net_end(&new_thd->net);
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
started_events++;
|
||||
executed_events++; // For SHOW STATUS
|
||||
|
|
@ -566,17 +587,8 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
|
|||
error:
|
||||
DBUG_PRINT("error", ("Event_scheduler::execute_top() res: %d", res));
|
||||
if (new_thd)
|
||||
{
|
||||
new_thd->proc_info= "Clearing";
|
||||
DBUG_ASSERT(new_thd->net.buff != 0);
|
||||
net_end(&new_thd->net);
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
dec_thread_running();
|
||||
delete new_thd;
|
||||
mysql_cond_broadcast(&COND_thread_count);
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
}
|
||||
|
||||
delete event_name;
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue