summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_backup_stage.test
blob: 31d76816355f17fe0a91cdb129965616d3b563bc (plain)
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
#
# Check that BACKUP STAGE BLOCK_DDL desyncs and pauses the node until BACKUP STAGE END:
# - Local DDLs will fail immediately
# - Local DMLs will block until resync
# - Remote txns will be applied after resync (STAGE END).
# 

--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/have_metadata_lock_info.inc

--connection node_1
CREATE TABLE t1 (f1 varchar(10)) ENGINE=InnoDB;

# First, check that BACKUP STAGE END skipping desyncing stages is fine
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE END;

BACKUP STAGE START;
BACKUP STAGE FLUSH;

--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1a
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_retry_autocommit=0;
INSERT INTO t1 (f1) values ("node1_1");
ALTER TABLE t1 ADD COLUMN (f2 int(10));

--connection node_2
INSERT INTO t1 (f1) values ("node2_1");
ALTER TABLE t1 ADD COLUMN (f3 int(10));

# BLOCK_DDL desyncs and pauses the node
--connection node_1
BACKUP STAGE BLOCK_DDL;

--connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1c
SET SESSION wsrep_sync_wait=0;
--let $wait_condition = SELECT variable_value="Donor/Desynced" FROM information_schema.global_status WHERE variable_name="wsrep_local_state_comment"
--source include/wait_condition.inc

--connection node_2
INSERT INTO t1 (f1) values("node2_2");
ALTER TABLE t1 ADD COLUMN (f5 int(10));

--connection node_1a
--error ER_UNKNOWN_COM_ERROR
ALTER TABLE t1 ADD COLUMN (f4 int(10));
--let $insert_id = `SELECT CONNECTION_ID()`
--send INSERT INTO t1 (f1) values("node1a");

# the insert will block during commit inside the provider, in certify. We can't
# check for sure it is blocked there, so we wait for the thread to at least
# reach commit stage. In the unlikely case the interleaving is different, the
# result of the test should not change.
--connection node_1c
--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.processlist WHERE State='Commit' AND ID=$insert_id
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.metadata_lock_info WHERE TABLE_NAME='t1' AND THREAD_ID=$insert_id
--source include/wait_condition.inc

--connection node_1
BACKUP STAGE BLOCK_COMMIT;

# node only resumes/resyncs upon STAGE END
--connection node_1c
SELECT variable_value="Donor/Desynced" FROM information_schema.global_status WHERE variable_name="wsrep_local_state_comment";

--connection node_2
INSERT INTO t1 (f1) values("node2_3");
ALTER TABLE t1 ADD COLUMN (f6 int(10));

--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1b
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_retry_autocommit=0;
--error ER_UNKNOWN_COM_ERROR
ALTER TABLE t1 ADD COLUMN (f4 int(10));
--let $insert_id = `SELECT CONNECTION_ID()`
--send INSERT INTO t1 (f1) values("node1b");

# wait for insert to get blocked
--connection node_1c
--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.processlist WHERE State='Commit' AND ID=$insert_id
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.metadata_lock_info WHERE TABLE_NAME='t1' AND THREAD_ID=$insert_id
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*)=2 FROM information_schema.processlist WHERE Info like 'INSERT INTO t1 (f1) values("node1%")' AND State = 'Commit'
--source include/wait_condition.inc

# nothing after BLOCK_DDL is applied
SELECT COUNT(*)=2 FROM t1;
SELECT COUNT(*)=3 FROM information_schema.columns WHERE table_name = 't1';

# STAGE END resumes and resyncs the node
--connection node_1
BACKUP STAGE END;

# Upon resume, blocked inserts will continue but conflict with the applying alters
--connection node_1a
--error ER_LOCK_DEADLOCK
--reap
--connection node_1b
--error ER_LOCK_DEADLOCK
--reap

--connection node_1
SELECT COUNT(*)=4 FROM t1;
SELECT COUNT(*)=5 FROM information_schema.columns WHERE table_name = 't1';

--connection node_2
SELECT COUNT(*)=4 FROM t1;
SELECT COUNT(*)=5 FROM information_schema.columns WHERE table_name = 't1';

--connection node_1
DROP TABLE t1;
call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
call mtr.add_suppression("greater than drain seqno");