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
|
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
--let $wsrep_max_ws_rows_orig = `SELECT @@wsrep_max_ws_rows`
SET GLOBAL wsrep_max_ws_rows = 4;
# Test that wsrep_max_ws_rows is enforced with multi statement transactions
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
INSERT INTO t1 (f2) VALUES (2);
INSERT INTO t1 (f2) VALUES (3);
INSERT INTO t1 (f2) VALUES (4);
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) VALUES (5);
COMMIT;
SELECT COUNT(*) = 0 FROM t1;
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
INSERT INTO t1 (f2) VALUES (2);
INSERT INTO t1 (f2) VALUES (3);
INSERT INTO t1 (f2) VALUES (4);
--error ER_ERROR_DURING_COMMIT
UPDATE t1 SET f2 = 10 WHERE f2 = 4;
COMMIT;
SELECT COUNT(*) = 0 FROM t1;
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
INSERT INTO t1 (f2) VALUES (2);
INSERT INTO t1 (f2) VALUES (3);
INSERT INTO t1 (f2) VALUES (4);
--error ER_ERROR_DURING_COMMIT
DELETE FROM t1 WHERE f2 = 1;
COMMIT;
SELECT COUNT(*) = 0 FROM t1;
# Test that wsrep_max_ws_rows is enforced on sigle statements
SET GLOBAL wsrep_max_ws_rows = 5;
INSERT INTO t1 (f2) VALUES (1),(2),(3),(4),(5);
SET GLOBAL wsrep_max_ws_rows = 4;
--error ER_ERROR_DURING_COMMIT
UPDATE t1 SET f2 = f2 + 10;
SELECT COUNT(*) = 5 FROM t1;
--error ER_ERROR_DURING_COMMIT
DELETE FROM t1 WHERE f2 < 10;
SELECT COUNT(*) = 5 FROM t1;
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) SELECT * FROM ten;
SELECT COUNT(*) = 5 FROM t1;
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) VALUES (10),(20),(30),(40),(50);
SELECT COUNT(*) = 5 FROM t1;
# Fewer than wsrep_max_ws_rows is OK
SET GLOBAL wsrep_max_ws_rows = 10;
DELETE FROM t1 WHERE f2 < 10;
SELECT COUNT(*) = 0 FROM t1;
# Test a series of transactions
--disable_query_log
SET GLOBAL wsrep_max_ws_rows = 5;
let $i= 100;
while ($i)
{
START TRANSACTION;
--eval INSERT INTO t1 (f2) VALUES ($i);
COMMIT;
dec $i;
}
--enable_query_log
SET GLOBAL wsrep_max_ws_rows = 100;
SELECT COUNT(*) = 100 FROM t1;
DELETE FROM t1 WHERE f2 < 101;
SELECT COUNT(*) = 0 FROM t1;
# Test large statements
SET GLOBAL wsrep_max_ws_rows = 9999;
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
SET GLOBAL wsrep_max_ws_rows = 10000;
INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
SET GLOBAL wsrep_max_ws_rows = 9999;
--error ER_ERROR_DURING_COMMIT
UPDATE t1 SET f2 = 2 WHERE f2 = 1;
SET GLOBAL wsrep_max_ws_rows = 10000;
UPDATE t1 SET f2 = 2 WHERE f2 = 1;
SET GLOBAL wsrep_max_ws_rows = 9999;
--error ER_ERROR_DURING_COMMIT
DELETE FROM t1 WHERE f2 = 2;
SET GLOBAL wsrep_max_ws_rows = 10000;
DELETE FROM t1 WHERE f2 = 2;
SELECT COUNT(*) = 0 FROM t1;
# Test that wsrep_max_ws_rows is reset when switching autocommit mode
SET AUTOCOMMIT = ON;
SET GLOBAL wsrep_max_ws_rows = 1;
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) VALUES (2);
INSERT INTO t1 (f2) VALUES (1);
INSERT INTO t1 (f2) VALUES (2);
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) VALUES (2);
INSERT INTO t1 (f2) VALUES (1);
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) VALUES (2);
# Test that wsrep_max_ws_rows is reset on implicit commits
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
START TRANSACTION;
INSERT INTO t1 (f2) VALUES (1);
--error ER_ERROR_DURING_COMMIT
INSERT INTO t1 (f2) VALUES (2);
DROP TABLE t1;
DROP TABLE ten;
--echo #
--echo # MDEV-11817: Altering a table with more rows than
--echo # wsrep_max_ws_rows causes cluster to break when running
--echo # Galera cluster in TOI mode
--echo #
--connection node_1
CREATE TABLE t1(c1 INT)ENGINE = INNODB;
SET GLOBAL wsrep_max_ws_rows= DEFAULT;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 SELECT * FROM t1;
SET GLOBAL wsrep_max_ws_rows= 1;
ALTER TABLE t1 CHANGE COLUMN c1 c1 BIGINT;
--connection node_2
SHOW CREATE TABLE t1;
SELECT COUNT(*) FROM t1;
DROP TABLE t1;
--connection node_1
--disable_query_log
--eval SET GLOBAL wsrep_max_ws_rows = $wsrep_max_ws_rows_orig
--enable_query_log
--source include/galera_end.inc
|