Merge lp:~laurynas-biveinis/percona-server/bug1397859 into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 704
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1397859
Merge into: lp:percona-server/5.6
Diff against target: 89 lines (+42/-0)
6 files modified
mysql-test/include/have_handler_socket.inc (+15/-0)
mysql-test/include/plugin.defs (+1/-0)
mysql-test/r/handler_socket.result (+4/-0)
mysql-test/t/handler_socket-master.opt (+1/-0)
mysql-test/t/handler_socket.test (+14/-0)
plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp (+7/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1397859
Reviewer Review Type Date Requested Status
George Ormond Lorch III (community) g2 Approve
Review via email: mp+243305@code.launchpad.net

Description of the change

Fix bug 1397859 (5.6 with enabled HandlerSocket hangs on shutdown).

There are two issues. First, dbcontex::term_thread calls
remove_global_thread with LOCK_thread_count locked, which is incorrect
after the fix for http://bugs.mysql.com/bug.php?id=69954, which makes
remove_global_thread to take that mutex. Fix by taking the mutex
conditionally in HandlerSocket.

Second, remove_global_thread fails with the debug assert that
thd->release_resources() has not been called yet. This function is
supposed to perform a part of THD::~THD destruction outside
LOCK_thread_count protection, so call it accordingly.

Add a testcase and support for testing HandlerSocket in MTR.

http://jenkins.percona.com/job/percona-server-5.6-param/763/

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

ST 48431

Revision history for this message
George Ormond Lorch III (gl-az) :
review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'mysql-test/include/have_handler_socket.inc'
--- mysql-test/include/have_handler_socket.inc 1970-01-01 00:00:00 +0000
+++ mysql-test/include/have_handler_socket.inc 2014-12-01 16:32:28 +0000
@@ -0,0 +1,15 @@
1if (`SELECT @@have_dynamic_loading != 'YES'`) {
2 --skip HandlerSocket plugin requires dynamic loading
3}
4
5if (!$HANDLER_SOCKET) {
6 --skip HandlerSocket plugin requires the environment variable $HANDLER_SOCKET to be set (normally done by MTR)
7}
8
9#
10# Check if --plugin-dir was setup for HandlerSocket
11#
12if (`SELECT CONCAT('--plugin-dir=', REPLACE(@@plugin_dir, '\\\\', '/')) != '$HANDLER_SOCKET_OPT/'`) {
13 --skip HandlerSocket plugin requires that --plugin-dir is set to the plugin dir (either the .opt file does not contain $HANDLER_SOCKET_OPT or another plugin is in use)
14}
15enable_query_log;
016
=== modified file 'mysql-test/include/plugin.defs'
--- mysql-test/include/plugin.defs 2014-12-01 07:53:48 +0000
+++ mysql-test/include/plugin.defs 2014-12-01 16:32:28 +0000
@@ -50,3 +50,4 @@
50adt_null plugin/audit_null AUDIT_NULL50adt_null plugin/audit_null AUDIT_NULL
51audit_log plugin/audit_log AUDIT_LOG audit_log51audit_log plugin/audit_log AUDIT_LOG audit_log
52query_response_time plugin/query_response_time PLUGIN_QUERY_RESPONSE_TIME QUERY_RESPONSE_TIME_AUDIT,QUERY_RESPONSE_TIME 52query_response_time plugin/query_response_time PLUGIN_QUERY_RESPONSE_TIME QUERY_RESPONSE_TIME_AUDIT,QUERY_RESPONSE_TIME
53handlersocket plugin/HandlerSocket-Plugin-for-MySQL HANDLER_SOCKET
5354
=== added file 'mysql-test/r/handler_socket.result'
--- mysql-test/r/handler_socket.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/handler_socket.result 2014-12-01 16:32:28 +0000
@@ -0,0 +1,4 @@
1call mtr.add_suppression("handlersocket: open_files_limit is too small");
2INSTALL PLUGIN handlersocket SONAME 'HANDLER_SOCKET';
3Restarting mysqld for bug 1397859 test...
4UNINSTALL PLUGIN handlersocket;
05
=== added file 'mysql-test/t/handler_socket-master.opt'
--- mysql-test/t/handler_socket-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/t/handler_socket-master.opt 2014-12-01 16:32:28 +0000
@@ -0,0 +1,1 @@
1$HANDLER_SOCKET_OPT --loose-handlersocket-port=9998
02
=== added file 'mysql-test/t/handler_socket.test'
--- mysql-test/t/handler_socket.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/handler_socket.test 2014-12-01 16:32:28 +0000
@@ -0,0 +1,14 @@
1--source include/have_handler_socket.inc
2
3call mtr.add_suppression("handlersocket: open_files_limit is too small");
4
5--replace_result $HANDLER_SOCKET HANDLER_SOCKET
6eval INSTALL PLUGIN handlersocket SONAME '$HANDLER_SOCKET';
7
8#
9# Test for bug 1397859: mysqld crashes or hangs on HS plugin shutdown
10#
11--echo Restarting mysqld for bug 1397859 test...
12--source include/restart_mysqld.inc
13
14UNINSTALL PLUGIN handlersocket;
015
=== modified file 'plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp'
--- plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp 2014-05-26 07:38:54 +0000
+++ plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp 2014-12-01 16:32:28 +0000
@@ -351,7 +351,12 @@
351 unlock_tables_if();351 unlock_tables_if();
352 my_pthread_setspecific_ptr(THR_THD, 0);352 my_pthread_setspecific_ptr(THR_THD, 0);
353 {353 {
354 #if MYSQL_VERSION_ID >= 50600
355 thd->release_resources();
356 #endif
357 #if MYSQL_VERSION_ID < 50620
354 pthread_mutex_lock(&LOCK_thread_count);358 pthread_mutex_lock(&LOCK_thread_count);
359 #endif
355 #if MYSQL_VERSION_ID >= 50600360 #if MYSQL_VERSION_ID >= 50600
356 remove_global_thread(thd);361 remove_global_thread(thd);
357 #else362 #else
@@ -359,7 +364,9 @@
359 #endif364 #endif
360 delete thd;365 delete thd;
361 thd = 0;366 thd = 0;
367 #if MYSQL_VERSION_ID < 50620
362 pthread_mutex_unlock(&LOCK_thread_count);368 pthread_mutex_unlock(&LOCK_thread_count);
369 #endif
363 my_thread_end();370 my_thread_end();
364 }371 }
365}372}

Subscribers

People subscribed via source and target branches