Skip to content

Commit 231dc71

Browse files
Dyre Tjeldvollbjornmu
authored andcommitted
Bug#34356318: Cannot use admin interface with enterprise TP after fix for Bug#34160256
Problem: Using admin interface connections with enterprise TP would lead to SEGV. Solution: Check for admin_thread_group == nullptr to correctly handle admin interface connections when there is no dedicated admin thread group. Testing: Moved main.admin_interface and main.admin_interface_ipv4_mapped to inc files, so that they can be --sourced both from main and thread_pool suites. Change-Id: I8a5a8f52c40c45f1d01bfb60cd0ddd72a9bc3533
1 parent 058ea85 commit 231dc71

File tree

4 files changed

+379
-375
lines changed

4 files changed

+379
-375
lines changed
Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
--source include/check_ipv6.inc
2+
--echo #
3+
--echo # WL#12138 -- Add Admin Port
4+
--echo #
5+
6+
--disable_query_log
7+
CALL mtr.add_suppression("Failed to initialize TLS for channel: mysql_admin");
8+
CALL mtr.add_suppression("Failed to set up SSL because of the following SSL library error");
9+
--enable_query_log
10+
11+
--echo # Create the user u1
12+
CREATE USER u1;
13+
--echo # Grant the user u1 the privilege SERVICE_CONNECTION_ADMIN
14+
GRANT SERVICE_CONNECTION_ADMIN ON *.* TO u1;
15+
16+
--echo # Create the user u2
17+
CREATE USER u2;
18+
19+
--let $MYSQLD_LOG= $MYSQL_TMP_DIR/server.log
20+
--let $MYSQLD_DATADIR= `SELECT @@datadir`
21+
22+
--echo # Create the user u3
23+
CREATE USER u3;
24+
--echo # Grant the user u3 the privilege SERVICE_CONNECTION_ADMIN
25+
GRANT SUPER ON *.* TO u3;
26+
27+
--echo # Stop DB server which was created by MTR default
28+
--source include/shutdown_mysqld.inc
29+
30+
--echo # Test case 1
31+
--echo # Check that specially treated value :: is not allowed as part of
32+
--echo # option admin-address.
33+
--error 1
34+
--exec $MYSQLD_CMD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --secure-file-priv="" --admin-address=::
35+
36+
--let SEARCH_FILE=$MYSQLD_LOG
37+
--let SEARCH_PATTERN=Invalid value for command line option admin-address: '::'
38+
--source include/search_pattern.inc
39+
40+
--remove_file $MYSQLD_LOG
41+
42+
--echo # Test case 2
43+
--echo # Check that specially treated value * is not allowed as part of
44+
--echo # option admin-address.
45+
--error 1
46+
--exec $MYSQLD_CMD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --secure-file-priv="" --admin-address=*
47+
48+
--let SEARCH_FILE=$MYSQLD_LOG
49+
--let SEARCH_PATTERN=Invalid value for command line option admin-address: '*'
50+
--source include/search_pattern.inc
51+
52+
--remove_file $MYSQLD_LOG
53+
54+
--echo # Test case 3
55+
--echo # Check that specially treated value 0.0.0.0 is not allowed as part of
56+
--echo # option admin-address.
57+
--error 1
58+
--exec $MYSQLD_CMD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --secure-file-priv="" --admin-address=0.0.0.0
59+
60+
--let SEARCH_FILE=$MYSQLD_LOG
61+
--let SEARCH_PATTERN=Invalid value for command line option admin-address: '0.0.0.0'
62+
--source include/search_pattern.inc
63+
64+
--remove_file $MYSQLD_LOG
65+
66+
--echo # Test case 4
67+
--echo # Check that non-existent host name specified as a value of the option admin-address results in error on server starting up.
68+
--echo # option admin-address.
69+
--error 1
70+
--exec $MYSQLD_CMD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --secure-file-priv="" --admin-address=non_existent_host
71+
72+
--let SEARCH_FILE=$MYSQLD_LOG
73+
--let SEARCH_PATTERN=Can't start server: cannot resolve hostname
74+
--source include/search_pattern.inc
75+
76+
--remove_file $MYSQLD_LOG
77+
78+
--echo # Starting up server with --admin-address=127.0.0.1 --max-connections=2
79+
--force-cpdir $MYSQLD_DATADIR $MYSQL_TMP_DIR/newdd
80+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
81+
--let $restart_parameters=restart: --admin-address=127.0.0.1 --admin-port=$MASTER_ADMINPORT --max-connections=2
82+
--source include/start_mysqld.inc
83+
--source include/xplugin_wait_for_interfaces.inc
84+
85+
--enable_connect_log
86+
--echo # Test case 5
87+
--echo # Check that ordinary connection using tcp protocol can be established
88+
89+
--connect(ordinary_tcp_con,localhost,root,,,,,TCP)
90+
SELECT CURRENT_USER();
91+
92+
--disconnect ordinary_tcp_con
93+
--source include/wait_until_disconnected.inc
94+
95+
--echo # Check error when starting a server having admin port which is busy
96+
--error 1
97+
--exec $MYSQLD_CMD --log-error=$MYSQLD_LOG --datadir=$MYSQL_TMP_DIR/newdd --secure-file-priv="" --admin-address=127.0.0.1 --admin-port=$MASTER_ADMINPORT
98+
99+
--let SEARCH_FILE=$MYSQLD_LOG
100+
--let SEARCH_PATTERN=Can't start server: Bind on TCP/IP port: (Address .*in use|Only one usage of each socket address .* normally permitted)
101+
--source include/search_pattern.inc
102+
103+
--remove_file $MYSQLD_LOG
104+
--force-rmdir $MYSQL_TMP_DIR/newdd
105+
106+
--echo # Test case 6
107+
--echo # Check that ordinary connection using default connection method can be established
108+
109+
--connect(ordinary_con,localhost,root,,,,,)
110+
SELECT CURRENT_USER();
111+
112+
--disconnect ordinary_con
113+
--source include/wait_until_disconnected.inc
114+
115+
--echo # Test case 7
116+
--echo # Check that admin connection using tcp protocol can be established
117+
118+
--connect(admin_tcp_con,127.0.0.1,root,,,$MASTER_ADMINPORT,,TCP)
119+
SELECT CURRENT_USER();
120+
121+
--echo # Check that a system message about the admin interface is written
122+
--echo # to the error log
123+
let $log_error_file= `SELECT @@GLOBAL.log_error`;
124+
if($log_error_file == "stderr")
125+
{
126+
let $log_error_file = $MYSQLTEST_VARDIR/log/mysqld.1.err;
127+
}
128+
--let SEARCH_FILE=$log_error_file
129+
--let SEARCH_PATTERN=\[System\] \[MY\-[0-9]+\] \[Server\] Admin interface ready for connections, address: \'127.0.0.1\' port: $MASTER_ADMINPORT
130+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
131+
--source include/search_pattern.inc
132+
133+
--disconnect admin_tcp_con
134+
--source include/wait_until_disconnected.inc
135+
136+
--echo # Test case 8
137+
--echo # Check that the user u1 can establish connection to admin interface since
138+
--echo # this user has the privilege SERVICE_CONNECTION_ADMIN
139+
--connect(admin_tcp_con_u1,127.0.0.1,u1,,,$MASTER_ADMINPORT,,TCP)
140+
SELECT CURRENT_USER();
141+
142+
--disconnect admin_tcp_con_u1
143+
--source include/wait_until_disconnected.inc
144+
145+
--echo # Test case 9
146+
--echo # Check that the user u2 can't establish connection to admin interface since
147+
--echo # this user doesn't have the privilege SERVICE_CONNECTION_ADMIN
148+
--connection default
149+
--source include/count_sessions.inc
150+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_ADMINPORT ADMIN_PORT
151+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
152+
--connect(admin_tcp_con_u2,127.0.0.1,u2,,,$MASTER_ADMINPORT,,TCP)
153+
154+
--echo # Check that the user u3 can't establish connection to admin interface since
155+
--echo # this user doesn't have the privilege SERVICE_CONNECTION_ADMIN
156+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_ADMINPORT ADMIN_PORT
157+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
158+
--connect(admin_tcp_con_u3,127.0.0.1,u3,,,$MASTER_ADMINPORT,,TCP)
159+
--connection default
160+
161+
--echo # Wait until the failed connections are gone.
162+
--source include/wait_until_count_sessions.inc
163+
164+
--echo # Test case 10
165+
--echo # Check that the parameter max_connections does affect to an ordinary
166+
--echo # connection and doesn't affect to a connection made to admin interface
167+
--connect(ordinary_con_1,localhost,u1,,,,,)
168+
169+
--echo # Show how many active connections exist after the connection
170+
--echo # ordinary_con_1 established
171+
SHOW STATUS LIKE 'Threads_connected';
172+
173+
--echo # Since server was started with the option --max-connections=2 and
174+
--echo # there are already two active connections (the first one is for
175+
--echo # the default connection and the second one is for the connection
176+
--echo # ordinary_con_1) an attempt to connect to the server results in
177+
--echo # error ER_CON_COUNT_ERROR
178+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
179+
--error ER_CON_COUNT_ERROR
180+
--connect(ordinary_con_2,localhost,u2,,,,,)
181+
182+
--echo # Check that attempt to establish the third connection to admin interface
183+
--echo # doesn't result in error
184+
--connect(admin_con_3,localhost,u1,,,$MASTER_ADMINPORT,,TCP)
185+
186+
--echo # Check that total number of concurrent connection made to admin interface
187+
--echo # is not limited by the value max-connections + 1
188+
--connect(admin_con_4,localhost,u1,,,$MASTER_ADMINPORT,,TCP)
189+
190+
--connection ordinary_con_1
191+
--disconnect ordinary_con_1
192+
--source include/wait_until_disconnected.inc
193+
194+
--connection admin_con_3
195+
--disconnect admin_con_3
196+
--source include/wait_until_disconnected.inc
197+
198+
--connection admin_con_4
199+
--disconnect admin_con_4
200+
--source include/wait_until_disconnected.inc
201+
202+
--connection default
203+
204+
--echo # Test case 11
205+
--echo # Check that a dedicated thread for handling connection requests
206+
--echo # on admin interface is not running in case a server started without
207+
--echo # the option --create-admin-listener-thread=true
208+
SELECT name, type FROM performance_schema.threads WHERE name = 'thread/sql/admin_interface';
209+
210+
--echo # Stop DB server
211+
--source include/shutdown_mysqld.inc
212+
213+
--echo # Starting up server with --admin-address=127.0.0.1,
214+
--echo # handle connections on admin interface by a dedicated thread
215+
--let $restart_parameters=restart: --admin-address=127.0.0.1 --admin-port=$MASTER_ADMINPORT --create-admin-listener-thread=true
216+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
217+
--source include/start_mysqld.inc
218+
219+
--echo # Test case 12
220+
--echo # Check that a dedicated thread for handling connection requests on
221+
--echo # admin interface is running in case a server started with the option
222+
--echo # --create-admin-listener-thread=true
223+
SELECT name, type FROM performance_schema.threads WHERE name = 'thread/sql/admin_interface';
224+
225+
--echo # Test case 13
226+
--echo # Check that admin connection using tcp protocol can be established
227+
--echo # when a server is started with option --create-admin-listener-thread=true
228+
229+
--connect(admin_tcp_con,127.0.0.1,root,,,$MASTER_ADMINPORT,,TCP)
230+
SELECT CURRENT_USER();
231+
232+
--disconnect admin_tcp_con
233+
--source include/wait_until_disconnected.inc
234+
235+
--echo # Test case 14
236+
--echo # Check that admin interface is turned off
237+
--echo # in case a server started with the --skip-networking option
238+
239+
--connection default
240+
--echo # Stop DB server
241+
--source include/shutdown_mysqld.inc
242+
243+
--echo # Starting up server with --admin-address=127.0.0.1 --skip-networking
244+
--let $restart_parameters=restart: --admin-address=127.0.0.1 --admin-port=$MASTER_ADMINPORT --skip-networking
245+
--let $wait_for_tcpsocket_status = no_wait
246+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
247+
--source include/start_mysqld.inc
248+
249+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_ADMINPORT ADMIN_PORT
250+
# Disable result_log to suppress output from subsequent connect() command
251+
# since it outputs error code reasoning why connection wasn't established
252+
# and its value could be distinct on different platforms.
253+
--disable_result_log
254+
--error CR_CONN_HOST_ERROR
255+
--connect(admin_tcp_con,127.0.0.1,root,,,$MASTER_ADMINPORT,,TCP)
256+
257+
--echo # Test case 15
258+
--echo # Check that admin interface is turned off in case a server started
259+
--echo # with the --skip-grant-tables option. If the server is started with
260+
--echo # the --skip-grant-tables option to disable authentication checks,
261+
--echo # the server enables --skip-networking automatically to prevent remote
262+
--echo # connections. Therefore, listening on admin interface must be disabled too.
263+
--connection default
264+
--echo # Stop DB server
265+
--source include/shutdown_mysqld.inc
266+
267+
--echo # Starting up server with --admin-address=127.0.0.1 --skip-grant-tables
268+
--let $restart_parameters=restart: --admin-address=127.0.0.1 --admin-port=$MASTER_ADMINPORT --skip-grant-tables
269+
--let $wait_for_tcpsocket_status = no_wait
270+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
271+
--source include/start_mysqld.inc
272+
273+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_ADMINPORT ADMIN_PORT
274+
# Disable result_log to suppress output from subsequent connect() command
275+
# since it outputs error code reasoning why connection wasn't established
276+
# and its value could be distinct on different platforms.
277+
--disable_result_log
278+
--error CR_CONN_HOST_ERROR
279+
--connect(admin_tcp_con,127.0.0.1,root,,,$MASTER_ADMINPORT,,TCP)
280+
281+
--connection default
282+
--echo # Stop DB server
283+
--source include/shutdown_mysqld.inc
284+
285+
--echo # Test case 16
286+
--echo # Check that admin interface is not setup when the option
287+
--echo # --admin-port is specified without --admin-address
288+
--let $restart_parameters=restart: --admin-port=$MASTER_ADMINPORT
289+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
290+
--source include/start_mysqld.inc
291+
292+
# Make ordinary connection
293+
--connect(ordinary_tcp_con,localhost,root,,,,,TCP)
294+
295+
SELECT CURRENT_USER();
296+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
297+
SELECT @@admin_address, @@admin_port;
298+
299+
--disconnect ordinary_tcp_con
300+
--source include/wait_until_disconnected.inc
301+
302+
# Connection through admin port shouldn't be possible
303+
# as --admin-address is not specified
304+
--disable_result_log
305+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_ADMINPORT ADMIN_PORT
306+
--error CR_CONN_HOST_ERROR
307+
--connect(admin_tcp_con,127.0.0.1,root,,,$MASTER_ADMINPORT,,TCP)
308+
--enable_result_log
309+
310+
--echo # Test case 17
311+
--echo # Check that we can connect to the server if admin
312+
--echo # interface is set up on loopback IPV6 address
313+
--connection default
314+
--let $restart_parameters=restart: --skip-name-resolve --admin-address="::1" --admin-port=$MASTER_ADMINPORT
315+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
316+
--source include/restart_mysqld.inc
317+
318+
--connect(admin_tcp_con_ipv6,::1,u1,,,$MASTER_ADMINPORT,,TCP)
319+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
320+
SELECT @@admin_address, @@admin_port;
321+
322+
--disconnect admin_tcp_con_ipv6
323+
--source include/wait_until_disconnected.inc
324+
325+
--connection default
326+
--echo # Stop DB server
327+
--source include/shutdown_mysqld.inc
328+
329+
--enable_result_log
330+
331+
--echo #
332+
--echo # Starting mysqld in the regular mode...
333+
--echo #
334+
--let $restart_parameters=
335+
--connection default
336+
337+
--source include/start_mysqld.inc
338+
339+
--echo # Cleaning up
340+
DROP USER u1;
341+
DROP USER u2;
342+
DROP USER u3;
343+
--disable_connect_log
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# The box should support IPv4-mapped addresses
2+
--source include/have_ipv4_mapped.inc
3+
4+
--disable_query_log
5+
CALL mtr.add_suppression("Failed to initialize TLS for channel: mysql_admin");
6+
CALL mtr.add_suppression("Failed to set up SSL because of the following SSL library error");
7+
--enable_query_log
8+
9+
# Check that if the admin interface is bound to an IPv4-mapped IPv6-address,
10+
# the server accepts client connections from both IPv4 and IPv6 worlds.
11+
12+
--let $restart_parameters=restart: --skip-name-resolve --admin-address=::ffff:127.0.0.1 --admin_port=$MASTER_ADMINPORT
13+
--replace_result $MASTER_ADMINPORT ADMIN_PORT
14+
--source include/restart_mysqld.inc
15+
16+
--source include/add_extra_root_users.inc
17+
18+
--echo # Checking ::ffff:127.0.0.1 ...
19+
--exec $MYSQLADMIN --no-defaults -h ::ffff:127.0.0.1 -P $MASTER_ADMINPORT -u root ping
20+
21+
--echo # Checking 127.0.0.1 ...
22+
--exec $MYSQLADMIN --no-defaults -h 127.0.0.1 -P $MASTER_ADMINPORT -u root ping
23+
24+
--source include/remove_extra_root_users.inc
25+
26+
# NOTE: ::1 has nothing to do with ::ffff:127.0.0.1, so the server bound to
27+
# ::ffff:127.0.0.1 will not accept connections from to ::1.
28+
29+
--echo #
30+
--echo # Starting mysqld in the regular mode...
31+
--echo #
32+
--let $restart_parameters=
33+
--connection default
34+
--source include/restart_mysqld.inc

0 commit comments

Comments
 (0)