################################################################################ # # WL#14166 - xproto: notify on connection close # ## Verify that MySQL Server send notice on X Protocol connections ## when it forces to close by sql query 'kill' --source include/big_test.inc --source include/xplugin_preamble.inc --source include/xplugin_create_user.inc ## Test case description: --echo ## I. Validate that X Plugin sends kill notice on IDLE connections --echo # --echo # Connect multiple clients, make the IDLE, and trigger kill, validate the notice --echo # --echo ## II. Validate that X Plugin sends kill notice on connections that process a query --echo # --echo # 1. A connection is waiting for lock --echo # 2. A connection is sleeping "SELECT SLEEP(A);" --echo # --echo ## III. Validate that X Plugin not sends kill notice on not authorized connections --echo # --echo ## Test starts here --let $xtest1_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_idle_connections.xpl --let $xtest2_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_working.xpl --let $xtest3_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_not_auth_connections.xpl --write_file $xtest1_file import assert_notices.macro; echo; echo #; echo # I; echo; echo #; echo # Creating sessions; repeat 10 %SESSION_ID%; newsession session_%SESSION_ID% x_root; endrepeat; echo; echo #; echo # Killing sessions; setsession; repeat 10 %SESSION_ID%; echo kill session_%SESSION_ID%; quiet; stmtsql SELECT id FROM information_schema.processlist WHERE command LIKE 'Sleep' AND user LIKE 'x_root' AND info LIKE "PLUGIN%" ORDER BY id; recvtovar %CONNECTION_ID_TO_KILL% id; KILL %CONNECTION_ID_TO_KILL%; noquiet; endrepeat; echo; echo #; echo # Reciving close notices; varlet %ER_SESSION_WAS_KILLED% 3169; repeat 10 %SESSION_ID%; setsession session_%SESSION_ID%; callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%; recvuntildisc show-received; endrepeat; EOF --write_file $xtest2_file import assert_notices.macro; echo; echo #; echo # II; CREATE TABLE test.some_table(some_column INT); -->sql DELIMITER // CREATE PROCEDURE test.loop_in_sp() BEGIN REPEAT SET @A=1; UNTIL FALSE END REPEAT; END // DELIMITER ; -->endsql echo; echo #; echo # Creating sessions; newsession session_WRITE_LOCK x_root; quiet; stmtsql SELECT connection_id() AS Value; noquiet; recvtovar %connection_id_WRITE_LOCK% Value; LOCK TABLE test.some_table WRITE; newsession session_READ_LOCK x_root; quiet; stmtsql SELECT connection_id() AS Value; noquiet; recvtovar %connection_id_READ_LOCK% Value; stmtsql SELECT * FROM test.some_table; newsession session_SLEEP x_root; quiet; stmtsql SELECT connection_id() AS Value; noquiet; recvtovar %connection_id_SLEEP% Value; stmtsql SELECT SLEEP(10000); newsession session_SP x_root; quiet; stmtsql SELECT connection_id() AS Value; noquiet; recvtovar %connection_id_SP% Value; stmtsql CALL test.loop_in_sp(); setsession; quiet; wait_for 3 SELECT count(*) FROM information_schema.processlist WHERE (state like "Waiting%" or state like "User sleep%" or state like 'closing tables%') and user = "x_root"; noquiet; echo; echo #; echo # Killing sessions; setsession; quiet; KILL %connection_id_READ_LOCK%; KILL %connection_id_SLEEP%; KILL %connection_id_SP%; KILL %connection_id_WRITE_LOCK%; noquiet; echo; echo #; echo # Reciving close notices; varlet %ER_SESSION_WAS_KILLED% 3169; varlet %ER_QUERY_INTERRUPTED% 1317; setsession session_WRITE_LOCK; callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%; recvuntildisc show-received; setsession session_READ_LOCK; recvtype Mysqlx.Error code %ER_QUERY_INTERRUPTED%; recvuntildisc show-received; setsession session_SLEEP; recvresult; callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%; recvuntildisc show-received; setsession session_SP; recvtype Mysqlx.Error code %ER_QUERY_INTERRUPTED%; recvuntildisc show-received; EOF --write_file $xtest3_file echo; echo #; echo # III; echo; echo #; echo # Creating sessions; repeat 10 %SESSION_ID%; newsession session_noauth_%SESSION_ID% -; # reciving ServerHello notice recvtype Mysqlx.Notice.Frame type 5; endrepeat; echo; echo #; echo # Killing sessions; setsession; repeat 10 %SESSION_ID%; echo kill session_noauth_%SESSION_ID%; quiet; stmtsql SELECT id FROM information_schema.processlist WHERE command NOT LIKE 'Killed' AND user LIKE 'unauthenticated user' AND info LIKE "PLUGIN%" ORDER BY id; recvtovar %CONNECTION_ID_TO_KILL% id; KILL %CONNECTION_ID_TO_KILL%; noquiet; endrepeat; echo; echo #; echo # Closing connection; repeat 10 %SESSION_ID%; setsession session_noauth_%SESSION_ID%; echo # `recvunitldisc` command must report disconnection without any other messages; recvuntildisc show-received; endrepeat; EOF --exec $MYSQLXTEST -ux_root --password='' --file=$xtest1_file 2>&1 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest2_file 2>&1 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest3_file 2>&1 ## Cleanup DROP TABLE test.some_table; DROP PROCEDURE test.loop_in_sp; --source ../include/xplugin_cleanup.inc