1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Fix for Bug#33507: Event scheduler creates more threads

than max_connections -- which results in user lockout.

The problem was that the variable thread_count that contains
the number of active threads was interpreted as a number of
active connections.

The fix is to introduce a new counter for active connections.


mysql-test/r/connect.result:
  A test case for Bug#33507: Event scheduler creates more threads
  than max_connections -- which results in user lockout.
mysql-test/t/connect.test:
  A test case for Bug#33507: Event scheduler creates more threads
  than max_connections -- which results in user lockout.
sql/mysql_priv.h:
  1. Polishing: login_connection() and end_connection() need not
     to be public.
  
  2. Introduce connection_count -- a variable to contain the number
     of active connections. It is protected by LOCK_connection_count.
sql/mysqld.cc:
  Use connection_count to count active connections.
sql/sql_connect.cc:
  1. Use connection_count to count active connections.
  2. Make login_connection(), end_connection() private for the module
  as they had to be.
This commit is contained in:
unknown
2008-03-12 17:44:40 +03:00
parent d80e7ce4e5
commit b279be388e
5 changed files with 231 additions and 14 deletions

View File

@@ -402,10 +402,11 @@ check_user(THD *thd, enum enum_server_command command,
if (check_count)
{
VOID(pthread_mutex_lock(&LOCK_thread_count));
bool count_ok= thread_count <= max_connections + delayed_insert_threads
|| (thd->main_security_ctx.master_access & SUPER_ACL);
VOID(pthread_mutex_unlock(&LOCK_thread_count));
pthread_mutex_lock(&LOCK_connection_count);
bool count_ok= connection_count <= max_connections ||
(thd->main_security_ctx.master_access & SUPER_ACL);
VOID(pthread_mutex_unlock(&LOCK_connection_count));
if (!count_ok)
{ // too many connections
my_error(ER_CON_COUNT_ERROR, MYF(0));
@@ -930,7 +931,7 @@ bool setup_connection_thread_globals(THD *thd)
*/
bool login_connection(THD *thd)
static bool login_connection(THD *thd)
{
NET *net= &thd->net;
int error;
@@ -968,7 +969,7 @@ bool login_connection(THD *thd)
This mainly updates status variables
*/
void end_connection(THD *thd)
static void end_connection(THD *thd)
{
NET *net= &thd->net;
plugin_thdvar_cleanup(thd);