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