File: gr_savepoint_crash.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (98 lines) | stat: -rw-r--r-- 3,778 bytes parent folder | download
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
################################################################################
# This test verifies the impact when a server is crashed during a incomplete
# transaction with savepoints in progress
#
# Test:
# 0. The test requires two servers: M1, M2
# 1. Create a table on M1.
# 2. Start a transaction t1 on M1, and crash the server M1 post savepoint and
#    check the status of server on restart.
# 3. Clean up
################################################################################

# This test does crashes servers, thence we skip it on valgrind.
--source include/not_valgrind.inc
--source include/big_test.inc
--source include/force_restart.inc

--source include/have_group_replication_plugin.inc
--source include/group_replication.inc

--let $member1_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $member2_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--echo #1. Create table t1 on M1
CREATE TABLE table1(a int primary key);
# Insert some values
INSERT INTO table1 values (1),(2);

--source include/rpl_sync.inc

--echo #2. Start transaction t1, crash server M1 post savepoint
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

# Transaction t1.
BEGIN;
INSERT INTO table1 VALUES (3);
SAVEPOINT s1;
UPDATE table1 SET a= -1 where a=1;
SAVEPOINT s2;

# Crash server
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--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
--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
--source include/kill_and_restart_mysqld.inc

--let $rpl_server_number= 1
--source include/rpl_reconnect.inc

# unblock group
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $group_replication_member_state= UNREACHABLE
--let $group_replication_member_id= $member1_uuid
--source include/gr_wait_for_member_state.inc

--replace_result $member2_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS1
eval SET GLOBAL group_replication_force_members= "$member2_group_replication_local_address";

# rejoin M1 to group
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_group_replication.inc

# Upon start wait until server M1 comes online.
let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where member_state= "ONLINE";
--source include/wait_condition.inc

# check that incomplete transaction t1 is rolled back, table1 should have only 2 tuples.
--let $assert_text= 'There should be two values in table1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM table1, count, 1] = 2
--source include/assert.inc

--echo 3. Clean-up
DROP TABLE table1;

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

set session sql_log_bin=0;
call mtr.add_suppression("The member lost contact with a majority of the members in the group. Until the network is restored.*");
call mtr.add_suppression("The member resumed contact with a majority of the members in the group.*");
set session sql_log_bin=1;

--source include/group_replication_end.inc