File: galera_bf_kill.test

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (232 lines) | stat: -rw-r--r-- 6,158 bytes parent folder | download | duplicates (3)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
--source include/galera_cluster.inc
--source include/have_innodb.inc

#
# Test case 1: Start a transaction on node_2a and kill it
# from other connection on same node
#

--connection node_2
call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
CREATE TABLE t1(a int not null primary key auto_increment,b int) engine=InnoDB;
insert into t1 values (NULL,1);

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
begin;
update t1 set a = 5;

--connection node_2

--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1
--source include/wait_condition.inc

--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1`

--disable_query_log
--eval KILL $k_thread
--enable_query_log

select * from t1;
--disconnect node_2a

#
# Test case 2: Start a transaction on node_2a and use
# kill query from other connection on same node
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
begin;
update t1 set a =5;

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1
--source include/wait_condition.inc

--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1`

--disable_query_log
--eval KILL QUERY $k_thread
--enable_query_log

select * from t1;
--disconnect node_2a
#
# Test case 3: Start a transaction on node_2a and start a DDL on other transaction
# that will then abort node_2a transaction
#
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
begin;
update t1 set a =5, b=2;

--connection node_2
ALTER TABLE t1 ADD UNIQUE KEY b1(b);
ALTER TABLE t1 DROP KEY b1;

select * from t1;

--disconnect node_2a

#
# Test case 4: Start a transaction on node_2a and conflicting transaction on node_2b
# and start a DDL on other transaction that will then abort node_2a and node_2b
# transactions
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
begin;
update t1 set a =5, b=2;

--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2b
begin;
send update t1 set a =6, b=7;

--connection node_2
ALTER TABLE t1 ADD UNIQUE KEY b2(b);
ALTER TABLE t1 DROP KEY b2;

select * from t1;

--disconnect node_2a
--disconnect node_2b

#
# Test case 5: Start a transaction on node_2a with wsrep disabled.
# A conflicting DDL on other transaction can't BF abort
# transaction from node_2a (wsrep disabled).
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
SET SESSION wsrep_on=OFF;
begin;
update t1 set a =5, b=2;

--connection node_2
--send ALTER TABLE t1 ADD UNIQUE KEY b3(b)

--connection node_2b
SET SESSION wsrep_sync_wait=0;
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Waiting for table metadata lock%' OR STATE LIKE 'Waiting to execute in isolation%';
--source include/wait_condition.inc

--connection node_2a
select * from t1;

# We expect that ALTER should not be able to BF abort
# this transaction, it must wait for it to finish.
# Expect commit to succeed.
commit;

--connection node_2
--reap

--disconnect node_2a
--disconnect node_2b

#
# Test case 6: Start a transaction on node_2a with wsrep disabled
# and kill it from other connection on same node.
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
SET SESSION wsrep_on=OFF;
begin;
update t1 set a =5, b=2;

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1
--source include/wait_condition.inc

--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1`

--disable_query_log
--eval KILL $k_thread
--enable_query_log

select * from t1;

--disconnect node_2a

--connection node_1

source include/maybe_debug.inc;
if ($have_debug) {
#
# Test case 7: Start a transaction on node_2 and use KILL to abort
# a query in connection node_2a
# During the KILL execution replicate conflicting transaction from node_1
# to BF abort the transaction executing the KILL
#

--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
truncate t1;
insert into t1 values (7,0);

--connection node_2
set wsrep_sync_wait=0;

# get the ID of connection to be later killed
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1
--source include/wait_condition.inc
--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1`

# start a transaction
begin;
update t1 set b=2 where a=7;

# set sync point for incoming applying
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2
set wsrep_sync_wait=0;

SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";

# replicate conflicting transaction, should stopp in the sync point
--connection node_1
update t1 set b=1 where a=7;

# wait for the applier to reach the sync point
--connection node_2b
SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached";

# issue KILL inside the transacion, implicit commit is expected
--connection node_2
--disable_query_log
--send_eval KILL QUERY $k_thread
--enable_query_log

# wait for the KILL processing to be seen in processlist
--connection node_2b
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND INFO LIKE 'KILL QUERY%'
--source include/wait_condition.inc

# resume applying, BF abort should follow
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";

--connection node_2
--error ER_LOCK_DEADLOCK
--reap

commit;

select * from t1;

--connection node_2a
SET DEBUG_SYNC= 'RESET';
SET GLOBAL debug_dbug = "";

--disconnect node_2a
--disconnect node_2b

--connection node_1
}

drop table t1;