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
|
# === Purpose ===
#
# This test checks the scenarios where the replica applier, when handling a
# table with a GIPK and data from an old source (before version 8.0.30) if
# the source table schema diverges too much in terms of column number there is
# a reported error.
# We also test a scenario where the replica assumes the source has a GIPK when
# it has instead an extra column to the right.
# Positive scenarios are also tested with a valid source table with no GIPK and
# a case where the source table as a key compatible with a GIPK.
#
# ==== Requirements ====
#
# R1. If the replica has a table with a GIPK and the source of replica is below
# 8.0.30, the source table must have the same number of columns or just one less.
#
# === Implementation ====
#
# 1. Create table t1 with a GIPK
# 2. Simulate replication from version 8.0.28 using a generated relay log from that version
# The table on the source only has 1 column, leading to an applier error
# 3. Simulate replication from version 5.7.41 using a generated relay log from that version
# The table on the source has 4 column, leading to an applier error
# 4. Simulate replication from version 8.0.28 using a generated relay log from that version
# The table on the source has 3 column, one extra on the right with a INT type, leading to an applier error
# 5. Simulate replication from version 8.0.28 using a generated relay log from that version
# The table on the source has 2 column, same fields as the replica but no GIPK
# 6. Simulate replication from version 5.7.41 using a generated relay log from that version
# The table on the source has 3 column, with a compatible key similar to a GIPK
# 7. # Clean up
#
# === References ===
#
# Wl#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key
#
--let $rpl_skip_start_slave = 1
--source include/not_have_privilege_checks_user.inc
--source include/master-slave.inc
--source include/have_binlog_format_row.inc
--echo
--echo ##################################################
--echo # 1. Create table t1 with a GIPK
--source include/rpl_connection_slave.inc
SET SESSION sql_generate_invisible_primary_key = ON;
CREATE TABLE t1 (c1 BIGINT, c2 TEXT);
SET SESSION sql_generate_invisible_primary_key = OFF;
--echo
--echo ##################################################
--echo # 2. Simulate replication from version 8.0.28 using a generated relay log from that version
--echo # The table on the source only has 1 column, leading to an applier error
# File contains INSERT INTO t1 VALUES (1);
--let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_low_column_number.000001
--source include/setup_fake_relay_log.inc
START REPLICA SQL_THREAD;
--let $slave_sql_errno= convert_error(ER_REPLICATION_INCOMPATIBLE_TABLE_WITH_GIPK)
--source include/wait_for_slave_sql_error.inc
--let $wait_condition= SELECT COUNT(*)>=1 FROM performance_schema.error_log WHERE error_code='MY-0$slave_sql_errno' AND data LIKE "%Failed to apply row event with 1 columns, originating from a server of version 8.0.28 on table 'test.t1', which has 3 columns%"
--source include/wait_condition.inc
--source include/cleanup_fake_relay_log.inc
--echo
--echo ##################################################
--echo # 3. Simulate replication from version 5.7.41 using a generated relay log from that version
--echo # The table on the source has 4 column, leading to an applier error
# File contains INSERT INTO t1 VALUES (1, 1, 1, 1);
--let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_high_column_number.000001
--source include/setup_fake_relay_log.inc
START REPLICA SQL_THREAD;
--let $slave_sql_errno= convert_error(ER_REPLICATION_INCOMPATIBLE_TABLE_WITH_GIPK)
--source include/wait_for_slave_sql_error.inc
--let $wait_condition= SELECT COUNT(*)>=1 FROM performance_schema.error_log WHERE error_code='MY-0$slave_sql_errno' AND data LIKE "% Failed to apply row event with 4 columns, originating from a server of version unknown on table 'test.t1', which has 3 columns%"
--source include/wait_condition.inc
--source include/cleanup_fake_relay_log.inc
--echo
--echo ##################################################
--echo # 4. Simulate replication from version 8.0.28 using a generated relay log from that version
--echo # The table on the source has 3 column, one extra on the right with a INT type, leading to an applier error
# File contains INSERT INTO t1 VALUES (1, 1, 1);
--let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_schema_divergence.000001
--source include/setup_fake_relay_log.inc
START REPLICA SQL_THREAD;
--let $slave_sql_errno= convert_error(ER_SERVER_REPLICA_CONVERSION_FAILED)
--source include/wait_for_slave_sql_error.inc
--let $wait_condition= SELECT COUNT(*)>=1 FROM performance_schema.error_log WHERE error_code='MY-0$slave_sql_errno' AND data LIKE "%Column 2 of table 'test.t1' cannot be converted from type 'bigint' to type 'text'%"
--source include/wait_condition.inc
--source include/cleanup_fake_relay_log.inc
--echo
--echo ##################################################
--echo # 5. Simulate replication from version 8.0.28 using a generated relay log from that version
--echo # The table on the source has 2 column, same fields as the replica but no GIPK
# File contains INSERT INTO t1 VALUES (1, '1');
--let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_minus_one_column_number.000001
--source include/setup_fake_relay_log.inc
START REPLICA SQL_THREAD;
--let $wait_condition= SELECT COUNT(*)>=1 FROM test.t1
--source include/wait_condition.inc
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE my_row_id = 1 AND c1 = 1 AND c2 = '1';`
--let $assert_text= Table t1 contains the inserted values
--let $assert_cond= $row_count = 1
--source include/assert.inc
--source include/stop_slave_sql.inc
--source include/cleanup_fake_relay_log.inc
--echo
--echo ##################################################
--echo # 6. Simulate replication from version 5.7.41 using a generated relay log from that version
--echo # The table on the source has 3 column, with a compatible key similar to a GIPK
# File contains INSERT INTO t1 VALUES (2, 2, '2');
--let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_gipk_equivalent_key.000001
--source include/setup_fake_relay_log.inc
START REPLICA SQL_THREAD;
--let $wait_condition= SELECT COUNT(*)>=2 FROM test.t1
--source include/wait_condition.inc
--let $row_count= `SELECT COUNT(*) FROM t1 WHERE my_row_id = 2 AND c1 = 2 AND c2 = '2';`
--let $assert_text= Table t1 contains the inserted values
--let $assert_cond= $row_count = 1
--source include/assert.inc
--echo
--echo ##################################################
--echo # 7. # Clean up
DROP TABLE t1;
STOP SLAVE SQL_THREAD;
--source include/cleanup_fake_relay_log.inc
--source include/start_slave.inc
let $messages =
Replica SQL for channel .*: Worker .* failed executing transaction .* at .* end_log_pos .* Failed to apply row event with 1 columns,
Replica SQL for channel .*: Worker .* failed executing transaction .* at .* end_log_pos .* Failed to apply row event with 4 columns
Replica SQL for channel .*: Worker .* failed executing transaction .* at .* end_log_pos .* Column 2 of table 'test.t1' cannot be converted from type
The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state
Replica SQL for channel .*: Failed to apply row event with 1 columns, originating from a server of version 8.0.28
Replica SQL for channel .*: Failed to apply row event with 4 columns, originating from a server of version unknown
Replica SQL for channel .*: Column 2 of table 'test.t1' cannot be converted from type
;
--let $suppress_on_current_connection = 1
--source include/suppress_messages.inc
--source include/rpl_end.inc
|