Bug#16865959 - PLEASE BACKPORT BUG 14749800.

Since log_throttle is not available in 5.5. Logging of
error message for failure of thread to create new connection
in "create_thread_to_handle_connection" is not backported.

Since, function "my_plugin_log_message" is not available in 
5.5 version and since there is incompatibility between
sql_print_XXX function compiled with g++ and alog files with
gcc to use sql_print_error, changes related to audit log
plugin is not backported.
This commit is contained in:
Praveenkumar Hulakund 2013-07-24 15:44:41 +05:30
commit 03940a7bd8
10 changed files with 123 additions and 77 deletions

View file

@ -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();
@ -360,26 +366,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");
@ -389,10 +395,16 @@ Event_scheduler::start()
if (state > INITIALIZED)
goto end;
DBUG_EXECUTE_IF("event_scheduler_thread_create_failure", {
*err_no= 11;
Events::opt_event_scheduler= Events::EVENTS_OFF;
ret= true;
goto end; });
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);
@ -415,28 +427,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);
}
@ -547,7 +561,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;
@ -557,17 +584,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);
}