| 1 |
################################################################################ |
| 2 |
# This test verifies the impact when a server is crashed during a incomplete |
| 3 |
# transaction with savepoints in progress |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires two servers: M1, M2 |
| 7 |
# 1. Create a table on M1. |
| 8 |
# 2. Start a transaction t1 on M1, and crash the server M1 post savepoint and |
| 9 |
# check the status of server on restart. |
| 10 |
# 3. Clean up |
| 11 |
################################################################################ |
| 12 |
|
| 13 |
# This test does crashes servers, thence we skip it on valgrind. |
| 14 |
--source include/not_valgrind.inc |
| 15 |
--source include/big_test.inc |
| 16 |
--source include/force_restart.inc |
| 17 |
|
| 18 |
--source include/have_group_replication_plugin.inc |
| 19 |
--source include/group_replication.inc |
| 20 |
|
| 21 |
--let $member1_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 22 |
--let $group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 23 |
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 24 |
|
| 25 |
--let $rpl_connection_name= server2 |
| 26 |
--source include/rpl_connection.inc |
| 27 |
|
| 28 |
--let $member2_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 29 |
|
| 30 |
--let $rpl_connection_name= server1 |
| 31 |
--source include/rpl_connection.inc |
| 32 |
|
| 33 |
--echo #1. Create table t1 on M1 |
| 34 |
CREATE TABLE table1(a int primary key); |
| 35 |
# Insert some values |
| 36 |
INSERT INTO table1 values (1),(2); |
| 37 |
|
| 38 |
--source include/rpl_sync.inc |
| 39 |
|
| 40 |
--echo #2. Start transaction t1, crash server M1 post savepoint |
| 41 |
--let $rpl_connection_name= server1 |
| 42 |
--source include/rpl_connection.inc |
| 43 |
|
| 44 |
# Transaction t1. |
| 45 |
BEGIN; |
| 46 |
INSERT INTO table1 VALUES (3); |
| 47 |
SAVEPOINT s1; |
| 48 |
UPDATE table1 SET a= -1 where a=1; |
| 49 |
SAVEPOINT s2; |
| 50 |
|
| 51 |
# Crash server |
| 52 |
--let $rpl_connection_name= server1 |
| 53 |
--source include/rpl_connection.inc |
| 54 |
|
| 55 |
--let $restart_parameters=restart:--group_replication_local_address=$member1_group_replication_local_address --group_replication_group_seeds=$group_replication_group_seeds --group_replication_group_name=$group_replication_group_name |
| 56 |
--replace_result $member1_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS1 $group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 57 |
--source include/kill_and_restart_mysqld.inc |
| 58 |
|
| 59 |
--let $rpl_server_number= 1 |
| 60 |
--source include/rpl_reconnect.inc |
| 61 |
|
| 62 |
# unblock group |
| 63 |
--let $rpl_connection_name= server2 |
| 64 |
--source include/rpl_connection.inc |
| 65 |
|
| 66 |
--let $group_replication_member_state= UNREACHABLE |
| 67 |
--let $group_replication_member_id= $member1_uuid |
| 68 |
--source include/gr_wait_for_member_state.inc |
| 69 |
|
| 70 |
--replace_result $member2_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS1 |
| 71 |
eval SET GLOBAL group_replication_force_members= "$member2_group_replication_local_address"; |
| 72 |
|
| 73 |
# rejoin M1 to group |
| 74 |
--let $rpl_connection_name= server1 |
| 75 |
--source include/rpl_connection.inc |
| 76 |
--source include/start_group_replication.inc |
| 77 |
|
| 78 |
# Upon start wait until server M1 comes online. |
| 79 |
let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where member_state= "ONLINE"; |
| 80 |
--source include/wait_condition.inc |
| 81 |
|
| 82 |
# check that incomplete transaction t1 is rolled back, table1 should have only 2 tuples. |
| 83 |
--let $assert_text= 'There should be two values in table1' |
| 84 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM table1, count, 1] = 2 |
| 85 |
--source include/assert.inc |
| 86 |
|
| 87 |
--echo 3. Clean-up |
| 88 |
DROP TABLE table1; |
| 89 |
|
| 90 |
--let $rpl_connection_name= server2 |
| 91 |
--source include/rpl_connection.inc |
| 92 |
|
| 93 |
set session sql_log_bin=0; |
| 94 |
call mtr.add_suppression("The member lost contact with a majority of the members in the group. Until the network is restored.*"); |
| 95 |
call mtr.add_suppression("The member resumed contact with a majority of the members in the group.*"); |
| 96 |
set session sql_log_bin=1; |
| 97 |
|
| 98 |
--source include/group_replication_end.inc |