MDEV-9156 : Fix tp_add_connection()'s error handling
Avoid possible my_thread_end() in the main polling thread.
This commit is contained in:
parent
ba8e630d97
commit
50160216ea
@ -27,6 +27,7 @@ extern uint threadpool_oversubscribe; /* Maximum active threads in group */
|
|||||||
|
|
||||||
|
|
||||||
/* Common thread pool routines, suitable for different implementations */
|
/* Common thread pool routines, suitable for different implementations */
|
||||||
|
extern void threadpool_cleanup_connection(THD *thd);
|
||||||
extern void threadpool_remove_connection(THD *thd);
|
extern void threadpool_remove_connection(THD *thd);
|
||||||
extern int threadpool_process_request(THD *thd);
|
extern int threadpool_process_request(THD *thd);
|
||||||
extern int threadpool_add_connection(THD *thd);
|
extern int threadpool_add_connection(THD *thd);
|
||||||
|
@ -168,22 +168,28 @@ int threadpool_add_connection(THD *thd)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
threadpool_cleanup_connection() does the bulk of connection shutdown work.
|
||||||
|
Usually called from threadpool_remove_connection(), but rarely it might
|
||||||
|
be called also in the main polling thread if connection initialization fails.
|
||||||
|
*/
|
||||||
|
void threadpool_cleanup_connection(THD *thd)
|
||||||
|
{
|
||||||
|
thd->net.reading_or_writing = 0;
|
||||||
|
end_connection(thd);
|
||||||
|
close_connection(thd, 0);
|
||||||
|
unlink_thd(thd);
|
||||||
|
mysql_cond_broadcast(&COND_thread_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void threadpool_remove_connection(THD *thd)
|
void threadpool_remove_connection(THD *thd)
|
||||||
{
|
{
|
||||||
|
|
||||||
Worker_thread_context worker_context;
|
Worker_thread_context worker_context;
|
||||||
worker_context.save();
|
worker_context.save();
|
||||||
|
|
||||||
thread_attach(thd);
|
thread_attach(thd);
|
||||||
thd->net.reading_or_writing= 0;
|
|
||||||
|
|
||||||
end_connection(thd);
|
|
||||||
close_connection(thd, 0);
|
|
||||||
|
|
||||||
unlink_thd(thd);
|
|
||||||
mysql_cond_broadcast(&COND_thread_count);
|
|
||||||
|
|
||||||
|
threadpool_cleanup_connection(thd);
|
||||||
/*
|
/*
|
||||||
Free resources associated with this connection:
|
Free resources associated with this connection:
|
||||||
mysys thread_var and PSI thread.
|
mysys thread_var and PSI thread.
|
||||||
|
@ -1255,7 +1255,7 @@ void tp_add_connection(THD *thd)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Allocation failed */
|
/* Allocation failed */
|
||||||
threadpool_remove_connection(thd);
|
threadpool_cleanup_connection(thd);
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@ -667,7 +667,7 @@ void tp_add_connection(THD *thd)
|
|||||||
if(!con)
|
if(!con)
|
||||||
{
|
{
|
||||||
tp_log_warning("Allocation failed", "tp_add_connection");
|
tp_log_warning("Allocation failed", "tp_add_connection");
|
||||||
threadpool_remove_connection(thd);
|
threadpool_cleanup_connection(thd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,7 +685,7 @@ void tp_add_connection(THD *thd)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Likely memory pressure */
|
/* Likely memory pressure */
|
||||||
login_callback(NULL, con, NULL); /* deletes connection if something goes wrong */
|
threadpool_cleanup_connection(thd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user