| 1 |
################################################################################ |
| 2 |
# BUG#22336669 - TIMEOUT WHILE SHUTTING DOWN THE SERVER WITH PREPARED PROCEDURES |
| 3 |
# RUNNING |
| 4 |
# |
| 5 |
# Test to check if the server hangs while a STOP GROUP_REPLICATION command is |
| 6 |
# executed and a stored procedure is running. |
| 7 |
# |
| 8 |
# Test: |
| 9 |
# 0. The test requires two servers: M1 and M2. |
| 10 |
# 1. With both the members ONLINE. On M1 create a table and stored procedure(SP) |
| 11 |
# to insert 199 rows in the table created. |
| 12 |
# 2. Set DEBUG point to hang SP at the before commit hook. Call SP and |
| 13 |
# simultaneously stop GR on M1. |
| 14 |
# 3. Signal to continue_commit. Check that BUG#22336669 fixes the hang. Wait |
| 15 |
# for the 199 rows in the table. |
| 16 |
# 4. Assert check that SP was executed only on M1's binary log and was logged |
| 17 |
# with M1's UUID. It never reached the binary log of M2. On M2 there is |
| 18 |
# only 5 transactions logged with group UUID. |
| 19 |
# 5. Clean up. |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
# Setup a two server Group. |
| 23 |
--source include/have_debug.inc |
| 24 |
--source include/set_privilege_checks_user_as_system_user.inc |
| 25 |
--source include/have_group_replication_plugin.inc |
| 26 |
--let $rpl_gtid_utils= 1 |
| 27 |
--source include/group_replication.inc |
| 28 |
|
| 29 |
--let $rpl_connection_name= server1 |
| 30 |
--source include/rpl_connection.inc |
| 31 |
|
| 32 |
SET SESSION sql_log_bin= 0; |
| 33 |
call mtr.add_suppression("Transaction cannot be executed while Group Replication is stopping."); |
| 34 |
call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed"); |
| 35 |
SET SESSION sql_log_bin= 1; |
| 36 |
|
| 37 |
# Create a stored procedure to insert rows in the table created. |
| 38 |
CREATE TABLE test.t1 (a INT PRIMARY KEY); |
| 39 |
USE test; |
| 40 |
delimiter $$; |
| 41 |
CREATE PROCEDURE insert_into_t1() |
| 42 |
BEGIN |
| 43 |
DECLARE x INT; |
| 44 |
SET x=1; |
| 45 |
WHILE x<200 DO |
| 46 |
INSERT INTO t1 VALUES (x); |
| 47 |
SET x=x+1; |
| 48 |
END WHILE; |
| 49 |
end$$ |
| 50 |
delimiter ;$$ |
| 51 |
--source include/rpl_sync.inc |
| 52 |
--echo |
| 53 |
|
| 54 |
# Call the procedure and simultaneously executed STOP GROUP_REPLICATION from a |
| 55 |
# new connection. |
| 56 |
--let $rpl_connection_name= server1 |
| 57 |
--source include/rpl_connection.inc |
| 58 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 59 |
SET @@GLOBAL.DEBUG='d,group_replication_before_commit_hook_wait'; |
| 60 |
|
| 61 |
--send CALL insert_into_t1() |
| 62 |
|
| 63 |
# Ensuring that the procedure actually hangs at the before commit hook. |
| 64 |
--let $rpl_connection_name= server_1 |
| 65 |
--source include/rpl_connection.inc |
| 66 |
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 67 |
--source include/wait_condition.inc |
| 68 |
|
| 69 |
# Leave group |
| 70 |
--send STOP GROUP_REPLICATION |
| 71 |
|
| 72 |
--let $rpl_connection_name= server_1_1 |
| 73 |
--source include/rpl_connection.inc |
| 74 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = 'thread/group_rpl/THD_mysql_thread_handler_read_only_mode' AND PROCESSLIST_STATE = 'Waiting for global read lock' |
| 75 |
--source include/wait_condition.inc |
| 76 |
|
| 77 |
SET DEBUG_SYNC='now SIGNAL continue_commit'; |
| 78 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 79 |
|
| 80 |
--let $rpl_connection_name= server1 |
| 81 |
--source include/rpl_connection.inc |
| 82 |
--error ER_RUN_HOOK_ERROR |
| 83 |
--reap |
| 84 |
|
| 85 |
# Wait for STOP GROUP_REPLICATION completion |
| 86 |
--let $rpl_connection_name= server_1 |
| 87 |
--source include/rpl_connection.inc |
| 88 |
--reap |
| 89 |
--let $group_replication_member_state= OFFLINE |
| 90 |
--source include/gr_wait_for_member_state.inc |
| 91 |
--source include/assert_and_disable_read_only.inc |
| 92 |
|
| 93 |
--source include/rpl_sync.inc |
| 94 |
|
| 95 |
# Asserting that the stored procedure was executed only on the group. |
| 96 |
--let $rows= `SELECT COUNT(*) AS count FROM t1` |
| 97 |
--let $last_gno= `SELECT $rows + 4` |
| 98 |
--let $assert_text= There are no local transactions. |
| 99 |
--let $assert_cond= GTID_IS_EQUAL("[SELECT @@GLOBAL.GTID_EXECUTED]", "$group_replication_group_name:1-$last_gno") |
| 100 |
--source include/assert.inc |
| 101 |
|
| 102 |
--let $rpl_connection_name= server2 |
| 103 |
--source include/rpl_connection.inc |
| 104 |
--let $assert_text= There are no local transactions. |
| 105 |
--let $assert_cond= GTID_IS_EQUAL("[SELECT @@GLOBAL.GTID_EXECUTED]", "$group_replication_group_name:1-$last_gno") |
| 106 |
--source include/assert.inc |
| 107 |
|
| 108 |
--let $diff_tables=server1:t1, server2:t1 |
| 109 |
--source include/diff_tables.inc |
| 110 |
|
| 111 |
# Cleanup |
| 112 |
--let $rpl_connection_name= server1 |
| 113 |
--source include/rpl_connection.inc |
| 114 |
DROP PROCEDURE insert_into_t1; |
| 115 |
DROP TABLE t1; |
| 116 |
|
| 117 |
--let $rpl_connection_name= server2 |
| 118 |
--source include/rpl_connection.inc |
| 119 |
DROP PROCEDURE insert_into_t1; |
| 120 |
DROP TABLE t1; |
| 121 |
--source include/stop_group_replication.inc |
| 122 |
|
| 123 |
--source include/group_replication_end.inc |