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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
|
#
# Test cases for stored procedure BF aborts.
#
--source include/galera_cluster.inc
--source include/galera_have_debug_sync.inc
--connection node_1
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
# Control connection for Galera sync point management
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1a
SET SESSION wsrep_sync_wait = 0;
--connection node_1
#
# Case 1a: Procedure does and UPDATE which will suffer BF abort
# but there is no actual conflict and non-conflicting INSERT.
# The expected outcome is that both UPDATE and INSERT will succedd
# and no errors are reported to the client, wsrep_local_replays is
# incremented by one.
#
DELIMITER |;
CREATE PROCEDURE proc_update_insert()
BEGIN
UPDATE t1 SET f2 = 'b';
INSERT INTO t1 VALUES (4, 'd');
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
SET SESSION wsrep_sync_wait = 0;
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_update_insert
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 1 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 1b: Procedure does and UPDATE which will suffer BF abort
# but there is no actual conflict and non-conflicting INSERT.
# An EXIT HANDLER is declared for the procedure.
# The expected outcome is that both UPDATE and INSERT will succedd
# and no errors are reported to the client, wsrep_local_replays is
# incremented by one.
#
DELIMITER |;
CREATE PROCEDURE proc_update_insert_with_exit_handler()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN END;
UPDATE t1 SET f2 = 'b';
INSERT INTO t1 VALUES (4, 'd');
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
SET SESSION wsrep_sync_wait = 0;
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_update_insert_with_exit_handler
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 1 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 1c: Procedure does and UPDATE which will suffer BF abort
# but there is no actual conflict and non-conflicting INSERT.
# A CONTINUE HANDLER is declared for the procedure.
# The expected outcome is that both UPDATE and INSERT will succedd
# and no errors are reported to the client, wsrep_local_replays is
# incremented by one.
#
DELIMITER |;
CREATE PROCEDURE proc_update_insert_with_continue_handler()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
UPDATE t1 SET f2 = 'b';
INSERT INTO t1 VALUES (4, 'd');
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
SET SESSION wsrep_sync_wait = 0;
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_update_insert_with_continue_handler
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 1 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 2a: UPDATE and INSERT are run inside a transaction and the transaction
# will be BF aborted on COMMIT. The expected outcome is that the transaction
# succeeds and no errors are reported to the client, wsrep_local_replays
# is incremented by one.
#
DELIMITER |;
CREATE PROCEDURE proc_update_insert_transaction()
BEGIN
START TRANSACTION;
UPDATE t1 SET f2 = 'b';
INSERT INTO t1 VALUES (4, 'd');
COMMIT;
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_update_insert_transaction
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
SET SESSION wsrep_sync_wait = 0;
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 1 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 2b: UPDATE and INSERT are run inside a transaction and the transaction
# will be BF aborted on COMMIT. A CONTINUE HANDLER is declared for the
# procedure. The expected outcome is that the transaction
# succeeds and no errors are reported to the client, wsrep_local_replays
# is incremented by one.
#
DELIMITER |;
CREATE PROCEDURE proc_update_insert_transaction_with_continue_handler()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
START TRANSACTION;
UPDATE t1 SET f2 = 'b';
INSERT INTO t1 VALUES (4, 'd');
COMMIT;
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_update_insert_transaction_with_continue_handler
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
SET SESSION wsrep_sync_wait = 0;
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 1 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 2c: UPDATE and INSERT are run inside a transaction and the transaction
# will be BF aborted on COMMIT. An EXIT HANDLE is declared for the procedure.
# The expected outcome is that the transaction succeeds and no errors are
# reported to the client, wsrep_local_replays is incremented by one.
#
DELIMITER |;
CREATE PROCEDURE proc_update_insert_transaction_with_exit_handler()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN END;
START TRANSACTION;
UPDATE t1 SET f2 = 'b';
INSERT INTO t1 VALUES (4, 'd');
COMMIT;
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_update_insert_transaction_with_exit_handler
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
SET SESSION wsrep_sync_wait = 0;
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 1 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 3a: Two INSERTs are run inside stored procedure, this time
# the first INSERT will have a BF abort and real conflict. The expected outcome
# is that the INSERT fails and an error is reported to the client.
# wsrep_local_replays is not incremented.
#
# Notice that the resulting error code may be both
# ER_DUP_ENTRY (procedure will exit with cert failure conflict state and
# will be) or ER_LOCK_DEADLOCK depending on timing.
#
DELIMITER |;
CREATE PROCEDURE proc_insert_insert_conflict()
BEGIN
INSERT INTO t1 VALUES (2, 'd');
INSERT INTO t1 VALUES (4, 'd');
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_insert_insert_conflict
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
SET SESSION wsrep_sync_wait = 0;
--source galera_sp_bf_abort.inc
--connection node_1
--error ER_DUP_ENTRY,ER_LOCK_DEADLOCK
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 0 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 3b: Two INSERTs are run inside stored procedure, this time
# the first INSERT will have a BF abort and real conflict.
# An EXIT HANDLER is declared for the procedure. The expected outcome
# is that the INSERT fails and an error is reported to the client.
# wsrep_local_replays is not incremented.
#
DELIMITER |;
CREATE PROCEDURE proc_insert_insert_conflict_with_exit_handler()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT "Conflict exit handler";
INSERT INTO t1 VALUES (2, 'd');
INSERT INTO t1 VALUES (4, 'd');
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_insert_insert_conflict_with_exit_handler
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
SET SESSION wsrep_sync_wait = 0;
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 0 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
--connection node_1
#
# Case 3c: Two INSERTs are run inside stored procedure, this time
# the first INSERT will have a BF abort and real conflict.
# A CONTINUE HANDLER is declared for the procedure. The expected outcome
# is that the the first INSERT fails but the second is executed without
# errors. wsrep_local_replays is not incremented.
#
DELIMITER |;
CREATE PROCEDURE proc_insert_insert_conflict_with_continue_handler()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT "Conflict continue handler";
INSERT INTO t1 VALUES (2, 'd');
INSERT INTO t1 VALUES (4, 'd');
END|
DELIMITER ;|
INSERT INTO t1 VALUES (1, 'a'), (3, 'a');
--let $wsrep_local_replays_orig = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--let $galera_sp_bf_abort_proc = proc_insert_insert_conflict_with_continue_handler
--let $galera_sp_bf_abort_conflict = INSERT INTO t1 VALUES (2, 'c')
SET SESSION wsrep_sync_wait = 0;
--source galera_sp_bf_abort.inc
--connection node_1
--reap
SET SESSION wsrep_sync_wait = default;
SELECT * FROM t1;
--let $wsrep_local_replays_curr = `SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_local_replays'`
--disable_query_log
--eval SELECT $wsrep_local_replays_curr - $wsrep_local_replays_orig = 0 AS wsrep_local_replays;
--enable_query_log
DELETE FROM t1;
DROP PROCEDURE proc_update_insert;
DROP PROCEDURE proc_update_insert_with_continue_handler;
DROP PROCEDURE proc_update_insert_with_exit_handler;
DROP PROCEDURE proc_update_insert_transaction;
DROP PROCEDURE proc_update_insert_transaction_with_continue_handler;
DROP PROCEDURE proc_update_insert_transaction_with_exit_handler;
DROP PROCEDURE proc_insert_insert_conflict;
DROP PROCEDURE proc_insert_insert_conflict_with_exit_handler;
DROP PROCEDURE proc_insert_insert_conflict_with_continue_handler;
DROP TABLE t1;
|