File: gr_readmode_on_autostart.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 (135 lines) | stat: -rw-r--r-- 4,912 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
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
124
125
126
127
128
129
130
131
132
133
134
135
################################################################################
# This test proves that the plugin will leave the group when it cannot enable
# the read mode in the server.
#
# Test:
#  0) The test requires two servers.
#  1) Bootstrap group with server 1.
#  2) Restart server 2 with start_on_boot=1 (to enable it for the install).
#  3) Insert some data on server 1.
#  4) Uninstall and Install the plugin on member 2 (auto start enabled on 2)
#     Use a debug point to make the read mode fail when connecting.
#  5) Verify that server 2 goes to ERROR state. Check that we cannot execute
#     transactions.
#  6) Check all is fine after restarting group replication on server 2.
#  7) Clean up.
################################################################################

--source include/big_test.inc
--source include/have_debug.inc
--let $group_replication_group_name= 7768a190-a421-11e5-a837-0800200c9a66
--source include/have_group_replication_plugin.inc
--source include/force_restart.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc

--echo #
--echo # Bootstrap group with server 1.
--echo #

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

--echo #
--echo # Restart group replication on server 2
--echo # with group_replication_start_on_boot=1
--echo #

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

set session sql_log_bin=0;
call mtr.add_suppression("Error when activating super_read_only mode on start. The member will now exit the group.");
call mtr.add_suppression("Transaction cannot be executed while Group Replication is on ERROR state.*");
call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed*");
call mtr.add_suppression("The member is leaving a group without being on one");
call mtr.add_suppression("The group replication user is not present in the server. The user will be recreated, please do not remove it");
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
call mtr.add_suppression("On plugin shutdown it was not possible to enable the server read only mode.*");
call mtr.add_suppression("The server was automatically set into offline mode after an error was detected.");
set session sql_log_bin=1;

SET @debug_save= @@GLOBAL.DEBUG;

--let $allow_rpl_inited= 1
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_start_on_boot=1
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
--source include/restart_mysqld.inc

# Needed as we are not using rpl_restart_server.inc
--let $rpl_server_number= 2
--source include/rpl_reconnect.inc
--let $group_replication_member_state= ONLINE
--source include/gr_wait_for_member_state.inc

--echo #
--echo # Add some data to server 1.
--echo #

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

CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);

-- source include/rpl_sync.inc

--echo #
--echo # On server 2 uninstall and install the plugin with auto start.
--echo # With debug set to group_replication_read_mode_error it should fail.
--echo #

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

--source include/uninstall_group_replication_plugin.inc

SET @@GLOBAL.DEBUG='d,group_replication_read_mode_error';

--source include/install_group_replication_plugin.inc

 --let $group_replication_member_state= ERROR
 --source include/gr_wait_for_member_state.inc

--let $assert_text= P_S table replication_group_members must only contain 1 member
--let $assert_cond= "[SELECT COUNT(*) FROM performance_schema.replication_group_members]" = 1
--source include/assert.inc

--source include/assert_and_disable_offline_mode.inc

--echo #
--echo # Check that we cannot execute transactions
--echo #

--error ER_RUN_HOOK_ERROR
INSERT INTO t1 VALUES (2);

--let $skip_assert_read_only= 1
--source include/stop_group_replication.inc

--echo #
--echo # On server 2 after restarting GR all should be fine.
--echo #

SET @@GLOBAL.DEBUG= @debug_save;
--source include/start_group_replication.inc

INSERT INTO t1 VALUES (2);

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

# The data should be there.
--let $wait_condition= SELECT COUNT(*) = 2 FROM t1;
--source include/wait_condition.inc

--echo #
--echo # Clean up
--echo #

DROP TABLE t1;

--source include/group_replication_end.inc