| 1 |
# |
| 2 |
# Test cases for WL#5597 |
| 3 |
# |
| 4 |
# In this file, we only test for the following cases: |
| 5 |
|
| 6 |
# |
| 7 |
# CASE #1: update/delete multiple records from a table that share the |
| 8 |
# same hashtable key (in slave HASH_SCAN algorithm). |
| 9 |
|
| 10 |
# |
| 11 |
# CASE #2: same as CASE #1, but the reason is that the master has more |
| 12 |
# columns than the slave, thence duplicate keys in slave's |
| 13 |
# hashtable are a side effect, but should not be a problem. |
| 14 |
|
| 15 |
# |
| 16 |
# CASE #3: the slave stops gracefully when it is updating a row that |
| 17 |
# does not exist on its table. |
| 18 |
|
| 19 |
# |
| 20 |
# CASE #4: update/delete multiple records with blobs. Given that blobs |
| 21 |
# are not included in hashing, some records keys will collide. |
| 22 |
|
| 23 |
# |
| 24 |
# CASE #5: update/delete tables with only blob columns. |
| 25 |
# |
| 26 |
|
| 27 |
-- source include/not_group_replication_plugin.inc |
| 28 |
-- source include/have_binlog_format_row.inc |
| 29 |
-- source include/master-slave.inc |
| 30 |
|
| 31 |
# sql_replica_skip_counter is not supported with compression |
| 32 |
--source include/not_binlog_transaction_compression_on.inc |
| 33 |
|
| 34 |
SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; |
| 35 |
|
| 36 |
call mtr.add_suppression("Replica SQL for channel '': .*Could not execute Update_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's source log master-bin.[0-9]*, end_log_pos [0-9]*, Error_code: MY-001032"); |
| 37 |
call mtr.add_suppression("Replica: Can't find record in 't1' Error_code: MY-001032"); |
| 38 |
call mtr.add_suppression("Replica SQL for channel '': .*Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's source log master-bin.[0-9]*, end_log_pos [0-9]*, Error_code: MY-001032"); |
| 39 |
call mtr.add_suppression("Replica SQL for channel '': ... The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state. A restart should restore consistency automatically, although using non-transactional storage for data or info tables or DDL queries could lead to problems. In such cases you have to examine your data (see documentation for details). Error_code: 1756"); |
| 40 |
call mtr.add_suppression("Replica SQL for channel '': .*Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's source log FIRST, end_log_pos [0-9]*, Error_code: MY-001032"); |
| 41 |
|
| 42 |
SET sql_mode = default; |
| 43 |
|
| 44 |
--connection slave |
| 45 |
SET @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms; |
| 46 |
SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,HASH_SCAN'; |
| 47 |
|
| 48 |
# |
| 49 |
# CASE #1: entries that generate the same key for the slave internal |
| 50 |
# hash table. |
| 51 |
# |
| 52 |
# ASSERTS that no updates are lost due to having multiple entries for |
| 53 |
# the same hashtable key in the slave HASH_SCAN. |
| 54 |
# |
| 55 |
|
| 56 |
-- connection master |
| 57 |
CREATE TABLE t1 (a INT); |
| 58 |
INSERT INTO t1 VALUES (1), (1), (2), (3); |
| 59 |
--source include/sync_slave_sql_with_master.inc |
| 60 |
DELETE FROM t1; |
| 61 |
|
| 62 |
# try to change the order of the rows in the engine. |
| 63 |
INSERT INTO t1 VALUES (2), (1), (3), (1); |
| 64 |
|
| 65 |
-- connection master |
| 66 |
UPDATE t1 SET a=1000 WHERE a=1; |
| 67 |
--source include/sync_slave_sql_with_master.inc |
| 68 |
|
| 69 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 70 |
-- source include/diff_tables.inc |
| 71 |
|
| 72 |
-- connection master |
| 73 |
DELETE FROM t1 WHERE a=1000; |
| 74 |
DELETE FROM t1 WHERE a=2 OR a=3; |
| 75 |
--source include/sync_slave_sql_with_master.inc |
| 76 |
|
| 77 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 78 |
-- source include/diff_tables.inc |
| 79 |
|
| 80 |
#cleanup for case#1 |
| 81 |
--connection master |
| 82 |
DROP TABLE t1; |
| 83 |
--source include/sync_slave_sql_with_master.inc |
| 84 |
|
| 85 |
-- source include/rpl_reset.inc |
| 86 |
|
| 87 |
# CASE #2: entries generating the same key for the slave internal |
| 88 |
# hashtable because master table has more columns than the |
| 89 |
# slave's. |
| 90 |
# |
| 91 |
# ASSERTS that no updates are lost due to having multiple entries for |
| 92 |
# the same hashtable key in the slave HASH_SCAN when master |
| 93 |
# has more tables than the slave. |
| 94 |
|
| 95 |
-- connection master |
| 96 |
|
| 97 |
SET SQL_LOG_BIN=0; |
| 98 |
CREATE TABLE t1 (a INT, b INT); |
| 99 |
SET SQL_LOG_BIN=1; |
| 100 |
-- connection slave |
| 101 |
CREATE TABLE t1 (a INT); |
| 102 |
-- connection master |
| 103 |
INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2); |
| 104 |
UPDATE t1 SET a=1000 WHERE a=1; |
| 105 |
|
| 106 |
SELECT * FROM t1; |
| 107 |
--source include/sync_slave_sql_with_master.inc |
| 108 |
SELECT * FROM t1; |
| 109 |
|
| 110 |
-- connection master |
| 111 |
DELETE FROM t1 WHERE a=1000; |
| 112 |
DELETE FROM t1 WHERE a=2; |
| 113 |
SELECT * FROM t1; |
| 114 |
--source include/sync_slave_sql_with_master.inc |
| 115 |
SELECT * FROM t1; |
| 116 |
|
| 117 |
#cleanup for case#2 |
| 118 |
--connection master |
| 119 |
DROP TABLE t1; |
| 120 |
--source include/sync_slave_sql_with_master.inc |
| 121 |
|
| 122 |
-- source include/rpl_reset.inc |
| 123 |
|
| 124 |
# |
| 125 |
# CASE #3: The master updates and deletes some row that the slave does |
| 126 |
# not have. |
| 127 |
# |
| 128 |
# ASSERTS that the slave shall fail gracefully when the row is not found. |
| 129 |
# |
| 130 |
|
| 131 |
-- connection master |
| 132 |
|
| 133 |
CREATE TABLE t1 (a INT); |
| 134 |
INSERT INTO t1 VALUES (1), (1), (2), (3); |
| 135 |
--source include/sync_slave_sql_with_master.inc |
| 136 |
DELETE FROM t1 WHERE a=1; |
| 137 |
DELETE FROM t1 WHERE a=2; |
| 138 |
|
| 139 |
-- connection master |
| 140 |
UPDATE t1 SET a=1000 WHERE a=1; |
| 141 |
-- let $slave_sql_errno= 1032 |
| 142 |
-- source include/wait_for_slave_sql_error_and_skip.inc |
| 143 |
|
| 144 |
-- connection master |
| 145 |
DELETE FROM t1 WHERE a=2; |
| 146 |
-- let $slave_sql_errno= 1032 |
| 147 |
-- source include/wait_for_slave_sql_error_and_skip.inc |
| 148 |
DROP TABLE t1; |
| 149 |
--source include/sync_slave_sql_with_master.inc |
| 150 |
|
| 151 |
-- source include/rpl_reset.inc |
| 152 |
|
| 153 |
# |
| 154 |
# CASE #4: covers the case of tables that have blobs in them. |
| 155 |
# |
| 156 |
# ASSERTS that there are no lost updates |
| 157 |
|
| 158 |
-- connection master |
| 159 |
|
| 160 |
CREATE TABLE t1 (a INT, b TINYBLOB); |
| 161 |
INSERT INTO t1 VALUES (1,'a'), (1, 'b'), (2,'aa'), (2, 'aa'); |
| 162 |
|
| 163 |
UPDATE t1 SET b='c' WHERE a=1; |
| 164 |
--source include/sync_slave_sql_with_master.inc |
| 165 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 166 |
-- source include/diff_tables.inc |
| 167 |
|
| 168 |
-- connection master |
| 169 |
|
| 170 |
UPDATE t1 SET a=10000 WHERE b='aa'; |
| 171 |
--source include/sync_slave_sql_with_master.inc |
| 172 |
|
| 173 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 174 |
-- source include/diff_tables.inc |
| 175 |
|
| 176 |
-- connection master |
| 177 |
|
| 178 |
UPDATE t1 SET b='c' WHERE b='aa'; |
| 179 |
--source include/sync_slave_sql_with_master.inc |
| 180 |
|
| 181 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 182 |
-- source include/diff_tables.inc |
| 183 |
|
| 184 |
-- connection master |
| 185 |
|
| 186 |
DELETE FROM t1 WHERE b='c'; |
| 187 |
--source include/sync_slave_sql_with_master.inc |
| 188 |
|
| 189 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 190 |
-- source include/diff_tables.inc |
| 191 |
|
| 192 |
#cleanup for case#4 |
| 193 |
--connection master |
| 194 |
DROP TABLE t1; |
| 195 |
--source include/sync_slave_sql_with_master.inc |
| 196 |
|
| 197 |
-- source include/rpl_reset.inc |
| 198 |
|
| 199 |
# |
| 200 |
# CASE #5: covers the case in which the table has only blobs in it. |
| 201 |
# |
| 202 |
# ASSERTS that there are no issues even if blobs are skipped from the |
| 203 |
# hashing. Tables on master and slave will not go out-of-sync. |
| 204 |
# |
| 205 |
|
| 206 |
-- connection master |
| 207 |
|
| 208 |
CREATE TABLE t1 (a TINYBLOB, b TINYBLOB); |
| 209 |
INSERT INTO t1 VALUES ('a','a'), ('b', 'b'), ('a','aa'), ('a', 'aa'); |
| 210 |
|
| 211 |
UPDATE t1 SET b='c' WHERE b='aa'; |
| 212 |
--source include/sync_slave_sql_with_master.inc |
| 213 |
|
| 214 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 215 |
-- source include/diff_tables.inc |
| 216 |
|
| 217 |
-- connection master |
| 218 |
|
| 219 |
DELETE FROM t1; |
| 220 |
--source include/sync_slave_sql_with_master.inc |
| 221 |
|
| 222 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 223 |
-- source include/diff_tables.inc |
| 224 |
|
| 225 |
-- connection master |
| 226 |
INSERT INTO t1 VALUES (NULL,NULL), (NULL, NULL); |
| 227 |
DELETE FROM t1; |
| 228 |
|
| 229 |
--source include/sync_slave_sql_with_master.inc |
| 230 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 231 |
-- source include/diff_tables.inc |
| 232 |
|
| 233 |
#cleanup for case#5 |
| 234 |
--connection master |
| 235 |
DROP TABLE t1; |
| 236 |
--source include/sync_slave_sql_with_master.inc |
| 237 |
SET @@global.slave_rows_search_algorithms= @saved_slave_rows_search_algorithms; |
| 238 |
--source include/rpl_end.inc |