| 1 |
--source include/have_ndb.inc |
| 2 |
--source include/have_binlog_format_mixed_or_row.inc |
| 3 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 4 |
|
| 5 |
|
| 6 |
--echo # |
| 7 |
--echo # Bug#33974581 Update of table with hidden key stops applier |
| 8 |
--echo # |
| 9 |
--echo # When Applier process changes to a hidden key table it need to read |
| 10 |
--echo # from NDB instead of just defining another update or write. Before the |
| 11 |
--echo # read can take place, any already defined operations need to be sent to |
| 12 |
--echo # NDB. This is done both in order to "read your own writes" as well as |
| 13 |
--echo # handle constraint violation and missing row errors in the same way as |
| 14 |
--echo # if the table with hidden key was not changed. |
| 15 |
--echo # |
| 16 |
|
| 17 |
--echo # |
| 18 |
--echo # 1) This test shows "read your own write" for table with hidden pk. |
| 19 |
--echo # Since the table has hidden pk the UPDATE will need to read rows |
| 20 |
--echo # from NDB, find the ones that match the condition and then update those. |
| 21 |
--echo # In order to make it possible for NDB to return the first INSERT it |
| 22 |
--echo # need to be prepared/flushed before starting to read. |
| 23 |
# NOTE! There is no guarantee that the two statements are binlogged in a single |
| 24 |
# epoch transaction (and so testing the fix), |
| 25 |
--echo # |
| 26 |
--source include/rpl_connection_master.inc |
| 27 |
CREATE TABLE t1 (a INT, b INT) engine = NDB; |
| 28 |
INSERT INTO t1 VALUES (1, 1); |
| 29 |
UPDATE t1 SET a=NULL where b=1; |
| 30 |
--source include/sync_slave_sql_with_master.inc |
| 31 |
|
| 32 |
--source include/rpl_connection_master.inc |
| 33 |
DROP TABLE t1; |
| 34 |
--source include/sync_slave_sql_with_master.inc |
| 35 |
|
| 36 |
--echo # |
| 37 |
--echo # 2) This tests show that applying changes to table with hidden pk |
| 38 |
--echo # ignore error(s) from previously defined changes (in the same epoch |
| 39 |
--echo # transaction) as they should. |
| 40 |
--echo # |
| 41 |
--source include/rpl_connection_master.inc |
| 42 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) engine = NDB; |
| 43 |
CREATE TABLE t2_hidden_pk (a INT, b INT) engine = NDB; |
| 44 |
CREATE TABLE t3_hidden_pk_unique (a INT, b INT, unique(b)) engine = NDB; |
| 45 |
CREATE TABLE t4_hidden_pk_index (a INT, b INT, index(b)) engine = NDB; |
| 46 |
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); |
| 47 |
INSERT INTO t2_hidden_pk VALUES (1,1), (2,2), (3,3), (4,4), (5,5); |
| 48 |
INSERT INTO t3_hidden_pk_unique VALUES (1,1), (2,2), (3,3), (4,4), (5,5); |
| 49 |
INSERT INTO t4_hidden_pk_index VALUES (1,1), (2,2), (3,3), (4,4), (5,5); |
| 50 |
--source include/sync_slave_sql_with_master.inc |
| 51 |
|
| 52 |
--source include/rpl_connection_slave.inc |
| 53 |
--echo ## Delete rows on replica to make it possible to change something |
| 54 |
--echo ## on the source that would then fail when applied on the replica. |
| 55 |
DELETE FROM t1 WHERE a = 5; |
| 56 |
DELETE FROM t2_hidden_pk WHERE a = 5; |
| 57 |
DELETE FROM t3_hidden_pk_unique WHERE a = 5; |
| 58 |
DELETE FROM t4_hidden_pk_index WHERE a = 5; |
| 59 |
|
| 60 |
--echo ## Case 1, pk table (the "normal" case) |
| 61 |
--echo ## - update row that does not exist on replica |
| 62 |
--echo ## - update pk table -> direct update |
| 63 |
# NOTE! relative order in binlog is not guaranteed, so whether the |
| 64 |
# error op is first or second in the batch is unknown. |
| 65 |
--source include/rpl_connection_master.inc |
| 66 |
BEGIN; |
| 67 |
UPDATE t1 SET b = 0 WHERE a = 5; |
| 68 |
UPDATE t1 SET b = 10 WHERE a = 1; |
| 69 |
COMMIT; |
| 70 |
--source include/sync_slave_sql_with_master.inc |
| 71 |
|
| 72 |
--echo ## Case 2, hidden pk table |
| 73 |
--echo ## - update row that does not exist on replica |
| 74 |
--echo ## - update hidden pk table -> uses scan |
| 75 |
# NOTE! relative order in binlog is not guaranteed, so whether the |
| 76 |
# error op is first or second in the batch is unknown. |
| 77 |
--source include/rpl_connection_master.inc |
| 78 |
BEGIN; |
| 79 |
UPDATE t1 SET b = 0 WHERE a = 5; |
| 80 |
UPDATE t2_hidden_pk SET b = 10 WHERE a = 1; |
| 81 |
COMMIT; |
| 82 |
--source include/sync_slave_sql_with_master.inc |
| 83 |
|
| 84 |
--echo ## Case 3, hidden pk table with unique index |
| 85 |
--echo ## - update row that does not exist on replica |
| 86 |
--echo ## - update hidden pk table with unique index -> uses index scan |
| 87 |
# NOTE! relative order in binlog is not guaranteed, so whether the |
| 88 |
# error op is first or second in the batch is unknown. |
| 89 |
--source include/rpl_connection_master.inc |
| 90 |
BEGIN; |
| 91 |
UPDATE t1 SET b = 0 WHERE a = 5; |
| 92 |
UPDATE t3_hidden_pk_unique SET a = 30 WHERE b < 3; |
| 93 |
COMMIT; |
| 94 |
--source include/sync_slave_sql_with_master.inc |
| 95 |
|
| 96 |
--echo ## Case 4, hidden pk table with index |
| 97 |
--echo ## - update row that does not exist on replica |
| 98 |
--echo ## - update hidden pk table with index -> uses index scan |
| 99 |
# NOTE! relative order in binlog is not guaranteed, so whether the |
| 100 |
# error op is first or second in the batch is unknown. Howevere, the use |
| 101 |
# of < may mean that there are multiple 'keyless' events in the |
| 102 |
# epoch, so the chance of one of them following the failing pk op is higher |
| 103 |
--source include/rpl_connection_master.inc |
| 104 |
BEGIN; |
| 105 |
UPDATE t1 SET b = 0 WHERE a = 5; |
| 106 |
UPDATE t4_hidden_pk_index SET a = 40 WHERE b < 4; |
| 107 |
COMMIT; |
| 108 |
--source include/sync_slave_sql_with_master.inc |
| 109 |
|
| 110 |
--echo # Cleanup |
| 111 |
--source include/rpl_connection_master.inc |
| 112 |
DROP TABLE t1, t2_hidden_pk, t3_hidden_pk_unique, t4_hidden_pk_index; |
| 113 |
--source include/sync_slave_sql_with_master.inc |
| 114 |
|
| 115 |
--source include/rpl_end.inc |