Skip to content

Commit 5c62d58

Browse files
committed
PS-9328: Fix for failures to shutdown server after execution of threadpool_debug test.
Problem: ======== MTR was unable to properly shutdown Percona Server after execution of threadpool_debug test and had to resort to killing it with SIGKILL. Analysis: ========= threadpool_debug test simulates OOM situation when creating new THD objects while processing new connections using threadpool plugin. This is done by injecting and error in Thread_pool_connection_handler::add_connection() method. The problem occurred because we failed to correctly decrement connections count before returning from this method in case of error, like it is done in add_connection() methods for other connection handlers. As result during server shutdown we tried to wait indefinitely until total number of connections will become 0, which never happened since the connections which we failed to create due to simulated OOM were counted as existing (even though they didn't really). Note that the above means that failure to properly shutdown probably could have been observed on user systems which use threadpool plugin in cases when establishment of new connections failed due to OOM. OTOH Percona Server/MySQL is likely to hit more serious problems in case of OOM anyway. Solution: ========= Thread_pool_connection_handler::add_connection() now decrements connection count in case of its failure as implementations of add_connection() for other connection handlers do. Fix is applied to both 8.0 and 8.4 as both branches are affected by this issue.
1 parent 646a7cf commit 5c62d58

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sql/threadpool_unix.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,7 @@ bool Thread_pool_connection_handler::add_connection(
11971197

11981198
if (unlikely(!thd)) {
11991199
channel_info->send_error_and_close_channel(ER_OUT_OF_RESOURCES, 0, false);
1200+
Connection_handler_manager::dec_connection_count();
12001201
DBUG_RETURN(true);
12011202
}
12021203

@@ -1206,6 +1207,7 @@ bool Thread_pool_connection_handler::add_connection(
12061207
thd->get_protocol_classic()->end_net();
12071208
delete thd;
12081209
channel_info->send_error_and_close_channel(ER_OUT_OF_RESOURCES, 0, false);
1210+
Connection_handler_manager::dec_connection_count();
12091211
DBUG_RETURN(true);
12101212
}
12111213

0 commit comments

Comments
 (0)