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
1=== added file 'mysql-test/include/have_handler_socket.inc'
2--- mysql-test/include/have_handler_socket.inc 1970-01-01 00:00:00 +0000
3+++ mysql-test/include/have_handler_socket.inc 2014-12-01 16:32:28 +0000
4@@ -0,0 +1,15 @@
5+if (`SELECT @@have_dynamic_loading != 'YES'`) {
6+ --skip HandlerSocket plugin requires dynamic loading
7+}
8+
9+if (!$HANDLER_SOCKET) {
10+ --skip HandlerSocket plugin requires the environment variable $HANDLER_SOCKET to be set (normally done by MTR)
11+}
12+
13+#
14+# Check if --plugin-dir was setup for HandlerSocket
15+#
16+if (`SELECT CONCAT('--plugin-dir=', REPLACE(@@plugin_dir, '\\\\', '/')) != '$HANDLER_SOCKET_OPT/'`) {
17+ --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)
18+}
19+enable_query_log;
20
21=== modified file 'mysql-test/include/plugin.defs'
22--- mysql-test/include/plugin.defs 2014-12-01 07:53:48 +0000
23+++ mysql-test/include/plugin.defs 2014-12-01 16:32:28 +0000
24@@ -50,3 +50,4 @@
25 adt_null plugin/audit_null AUDIT_NULL
26 audit_log plugin/audit_log AUDIT_LOG audit_log
27 query_response_time plugin/query_response_time PLUGIN_QUERY_RESPONSE_TIME QUERY_RESPONSE_TIME_AUDIT,QUERY_RESPONSE_TIME
28+handlersocket plugin/HandlerSocket-Plugin-for-MySQL HANDLER_SOCKET
29
30=== added file 'mysql-test/r/handler_socket.result'
31--- mysql-test/r/handler_socket.result 1970-01-01 00:00:00 +0000
32+++ mysql-test/r/handler_socket.result 2014-12-01 16:32:28 +0000
33@@ -0,0 +1,4 @@
34+call mtr.add_suppression("handlersocket: open_files_limit is too small");
35+INSTALL PLUGIN handlersocket SONAME 'HANDLER_SOCKET';
36+Restarting mysqld for bug 1397859 test...
37+UNINSTALL PLUGIN handlersocket;
38
39=== added file 'mysql-test/t/handler_socket-master.opt'
40--- mysql-test/t/handler_socket-master.opt 1970-01-01 00:00:00 +0000
41+++ mysql-test/t/handler_socket-master.opt 2014-12-01 16:32:28 +0000
42@@ -0,0 +1,1 @@
43+$HANDLER_SOCKET_OPT --loose-handlersocket-port=9998
44
45=== added file 'mysql-test/t/handler_socket.test'
46--- mysql-test/t/handler_socket.test 1970-01-01 00:00:00 +0000
47+++ mysql-test/t/handler_socket.test 2014-12-01 16:32:28 +0000
48@@ -0,0 +1,14 @@
49+--source include/have_handler_socket.inc
50+
51+call mtr.add_suppression("handlersocket: open_files_limit is too small");
52+
53+--replace_result $HANDLER_SOCKET HANDLER_SOCKET
54+eval INSTALL PLUGIN handlersocket SONAME '$HANDLER_SOCKET';
55+
56+#
57+# Test for bug 1397859: mysqld crashes or hangs on HS plugin shutdown
58+#
59+--echo Restarting mysqld for bug 1397859 test...
60+--source include/restart_mysqld.inc
61+
62+UNINSTALL PLUGIN handlersocket;
63
64=== modified file 'plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp'
65--- plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp 2014-05-26 07:38:54 +0000
66+++ plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp 2014-12-01 16:32:28 +0000
67@@ -351,7 +351,12 @@
68 unlock_tables_if();
69 my_pthread_setspecific_ptr(THR_THD, 0);
70 {
71+ #if MYSQL_VERSION_ID >= 50600
72+ thd->release_resources();
73+ #endif
74+ #if MYSQL_VERSION_ID < 50620
75 pthread_mutex_lock(&LOCK_thread_count);
76+ #endif
77 #if MYSQL_VERSION_ID >= 50600
78 remove_global_thread(thd);
79 #else
80@@ -359,7 +364,9 @@
81 #endif
82 delete thd;
83 thd = 0;
84+ #if MYSQL_VERSION_ID < 50620
85 pthread_mutex_unlock(&LOCK_thread_count);
86+ #endif
87 my_thread_end();
88 }
89 }

Subscribers

People subscribed via source and target branches