| 1 |
# |
| 2 |
# MW-329F Fix incorrect affected rows count after replay. |
| 3 |
# |
| 4 |
# This is a version of MW-329 without the infinite loop that |
| 5 |
# in the original test is closed by killing the connection. |
| 6 |
# |
| 7 |
|
| 8 |
--source include/galera_cluster.inc |
| 9 |
--source include/have_innodb.inc |
| 10 |
|
| 11 |
CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; |
| 12 |
|
| 13 |
# We start with a populated table |
| 14 |
INSERT INTO t1 (f1) VALUES (1),(65535); |
| 15 |
|
| 16 |
# |
| 17 |
# Run concurrent INSERTs |
| 18 |
# |
| 19 |
|
| 20 |
DELIMITER |; |
| 21 |
CREATE PROCEDURE proc_insert (repeat_count int) |
| 22 |
BEGIN |
| 23 |
DECLARE current_num int; |
| 24 |
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; |
| 25 |
SET current_num = 0; |
| 26 |
SET SESSION wsrep_sync_wait = 0; |
| 27 |
WHILE current_num < repeat_count do |
| 28 |
INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 )); |
| 29 |
SELECT SLEEP(0.1); |
| 30 |
SET current_num = current_num + 1; |
| 31 |
END WHILE; |
| 32 |
END| |
| 33 |
DELIMITER ;| |
| 34 |
|
| 35 |
--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 36 |
--connection node_1b |
| 37 |
--let $connection_id = `SELECT CONNECTION_ID()` |
| 38 |
--disable_query_log |
| 39 |
--disable_result_log |
| 40 |
--send CALL proc_insert(500); |
| 41 |
|
| 42 |
# |
| 43 |
# Run concurrent UPDATEs. We expect that each UPDATE will report that |
| 44 |
# some rows were matched and updated |
| 45 |
# |
| 46 |
|
| 47 |
--connection node_2 |
| 48 |
--let $count = 2 |
| 49 |
--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` |
| 50 |
|
| 51 |
while ($count) |
| 52 |
{ |
| 53 |
--let $signature = `SELECT LEFT(MD5(RAND()), 10)` |
| 54 |
--disable_query_log |
| 55 |
--error 0,ER_LOCK_DEADLOCK |
| 56 |
--eval UPDATE t1 SET f2 = '$signature' |
| 57 |
--enable_query_log |
| 58 |
--let $row_count = `SELECT ROW_COUNT()` |
| 59 |
if (`SELECT @@error_count = 0`) { |
| 60 |
if (`SELECT $row_count = 0`) { |
| 61 |
--die ROW_COUNT() = 0 |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
# |
| 66 |
# Ensure at least one replay happens |
| 67 |
# |
| 68 |
|
| 69 |
--let $wsrep_replays = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` |
| 70 |
--disable_query_log |
| 71 |
if (`SELECT $wsrep_replays - $wsrep_local_replays_old > 0`) { |
| 72 |
--dec $count |
| 73 |
} |
| 74 |
--enable_query_log |
| 75 |
} |
| 76 |
|
| 77 |
# |
| 78 |
# Confirm that some transaction replays occurred |
| 79 |
# |
| 80 |
|
| 81 |
--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` |
| 82 |
--disable_query_log |
| 83 |
--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old > 0 AS wsrep_local_replays; |
| 84 |
--enable_query_log |
| 85 |
|
| 86 |
# |
| 87 |
# getting execution results for --send |
| 88 |
# |
| 89 |
|
| 90 |
--connection node_1b |
| 91 |
--error 0,1317,2013,2026 |
| 92 |
--reap |
| 93 |
--enable_query_log |
| 94 |
--enable_result_log |
| 95 |
|
| 96 |
--connection node_1 |
| 97 |
DROP PROCEDURE proc_insert; |
| 98 |
DROP TABLE t1; |
| 99 |
|
| 100 |
--disconnect node_1b |
| 101 |
|
| 102 |
# Due to MW-330, Multiple "conflict state 3 after post commit" warnings if table is dropped while SP is running |
| 103 |
CALL mtr.add_suppression("WSREP: .* conflict state after post commit "); |
| 104 |
|
| 105 |
set global innodb_status_output=Default; |