Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_gipk_cross_version_schema_changes.test

raw
1 # === Purpose ===
2 #
3 # This test checks the scenarios where the replica applier, when handling a
4 # table with a GIPK and data from an old source (before version 8.0.30) if
5 # the source table schema diverges too much in terms of column number there is
6 # a reported error.
7 # We also test a scenario where the replica assumes the source has a GIPK when
8 # it has instead an extra column to the right.
9 # Positive scenarios are also tested with a valid source table with no GIPK and
10 # a case where the source table as a key compatible with a GIPK.
11 #
12 # ==== Requirements ====
13 #
14 # R1. If the replica has a table with a GIPK and the source of replica is below
15 # 8.0.30, the source table must have the same number of columns or just one less.
16 #
17 # === Implementation ====
18 #
19 # 1. Create table t1 with a GIPK
20 # 2. Simulate replication from version 8.0.28 using a generated relay log from that version
21 # The table on the source only has 1 column, leading to an applier error
22 # 3. Simulate replication from version 5.7.41 using a generated relay log from that version
23 # The table on the source has 4 column, leading to an applier error
24 # 4. Simulate replication from version 8.0.28 using a generated relay log from that version
25 # The table on the source has 3 column, one extra on the right with a INT type, leading to an applier error
26 # 5. Simulate replication from version 8.0.28 using a generated relay log from that version
27 # The table on the source has 2 column, same fields as the replica but no GIPK
28 # 6. Simulate replication from version 5.7.41 using a generated relay log from that version
29 # The table on the source has 3 column, with a compatible key similar to a GIPK
30 # 7. # Clean up
31 #
32 # === References ===
33 #
34 # Wl#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key
35 #
36
37 --let $rpl_skip_start_slave = 1
38 --source include/not_have_privilege_checks_user.inc
39 --source include/master-slave.inc
40 --source include/have_binlog_format_row.inc
41
42 --echo
43 --echo ##################################################
44 --echo # 1. Create table t1 with a GIPK
45
46 --source include/rpl_connection_slave.inc
47
48 SET SESSION sql_generate_invisible_primary_key = ON;
49 CREATE TABLE t1 (c1 BIGINT, c2 TEXT);
50 SET SESSION sql_generate_invisible_primary_key = OFF;
51
52 --echo
53 --echo ##################################################
54 --echo # 2. Simulate replication from version 8.0.28 using a generated relay log from that version
55 --echo # The table on the source only has 1 column, leading to an applier error
56
57 # File contains INSERT INTO t1 VALUES (1);
58 --let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_low_column_number.000001
59 --source include/setup_fake_relay_log.inc
60
61 START REPLICA SQL_THREAD;
62
63 --let $slave_sql_errno= convert_error(ER_REPLICATION_INCOMPATIBLE_TABLE_WITH_GIPK)
64 --source include/wait_for_slave_sql_error.inc
65
66 --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%"
67 --source include/wait_condition.inc
68
69 --source include/cleanup_fake_relay_log.inc
70
71 --echo
72 --echo ##################################################
73 --echo # 3. Simulate replication from version 5.7.41 using a generated relay log from that version
74 --echo # The table on the source has 4 column, leading to an applier error
75
76 # File contains INSERT INTO t1 VALUES (1, 1, 1, 1);
77 --let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_high_column_number.000001
78 --source include/setup_fake_relay_log.inc
79
80 START REPLICA SQL_THREAD;
81
82 --let $slave_sql_errno= convert_error(ER_REPLICATION_INCOMPATIBLE_TABLE_WITH_GIPK)
83 --source include/wait_for_slave_sql_error.inc
84
85 --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%"
86 --source include/wait_condition.inc
87
88 --source include/cleanup_fake_relay_log.inc
89
90 --echo
91 --echo ##################################################
92 --echo # 4. Simulate replication from version 8.0.28 using a generated relay log from that version
93 --echo # The table on the source has 3 column, one extra on the right with a INT type, leading to an applier error
94
95 # File contains INSERT INTO t1 VALUES (1, 1, 1);
96 --let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_schema_divergence.000001
97 --source include/setup_fake_relay_log.inc
98
99 START REPLICA SQL_THREAD;
100
101 --let $slave_sql_errno= convert_error(ER_SERVER_REPLICA_CONVERSION_FAILED)
102 --source include/wait_for_slave_sql_error.inc
103
104 --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'%"
105 --source include/wait_condition.inc
106
107 --source include/cleanup_fake_relay_log.inc
108
109 --echo
110 --echo ##################################################
111 --echo # 5. Simulate replication from version 8.0.28 using a generated relay log from that version
112 --echo # The table on the source has 2 column, same fields as the replica but no GIPK
113
114 # File contains INSERT INTO t1 VALUES (1, '1');
115 --let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_no_gipk_minus_one_column_number.000001
116 --source include/setup_fake_relay_log.inc
117
118 START REPLICA SQL_THREAD;
119
120 --let $wait_condition= SELECT COUNT(*)>=1 FROM test.t1
121 --source include/wait_condition.inc
122
123 --let $row_count= `SELECT COUNT(*) FROM t1 WHERE my_row_id = 1 AND c1 = 1 AND c2 = '1';`
124 --let $assert_text= Table t1 contains the inserted values
125 --let $assert_cond= $row_count = 1
126 --source include/assert.inc
127
128 --source include/stop_slave_sql.inc
129 --source include/cleanup_fake_relay_log.inc
130
131 --echo
132 --echo ##################################################
133 --echo # 6. Simulate replication from version 5.7.41 using a generated relay log from that version
134 --echo # The table on the source has 3 column, with a compatible key similar to a GIPK
135
136 # File contains INSERT INTO t1 VALUES (2, 2, '2');
137 --let $fake_relay_log = $MYSQL_TEST_DIR/std_data/rpl_gipk_equivalent_key.000001
138 --source include/setup_fake_relay_log.inc
139
140 START REPLICA SQL_THREAD;
141
142 --let $wait_condition= SELECT COUNT(*)>=2 FROM test.t1
143 --source include/wait_condition.inc
144
145 --let $row_count= `SELECT COUNT(*) FROM t1 WHERE my_row_id = 2 AND c1 = 2 AND c2 = '2';`
146 --let $assert_text= Table t1 contains the inserted values
147 --let $assert_cond= $row_count = 1
148 --source include/assert.inc
149
150 --echo
151 --echo ##################################################
152 --echo # 7. # Clean up
153
154 DROP TABLE t1;
155
156 STOP SLAVE SQL_THREAD;
157 --source include/cleanup_fake_relay_log.inc
158 --source include/start_slave.inc
159
160 let $messages =
161 Replica SQL for channel .*: Worker .* failed executing transaction .* at .* end_log_pos .* Failed to apply row event with 1 columns,
162 Replica SQL for channel .*: Worker .* failed executing transaction .* at .* end_log_pos .* Failed to apply row event with 4 columns
163 Replica SQL for channel .*: Worker .* failed executing transaction .* at .* end_log_pos .* Column 2 of table 'test.t1' cannot be converted from type
164 The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state
165 Replica SQL for channel .*: Failed to apply row event with 1 columns, originating from a server of version 8.0.28
166 Replica SQL for channel .*: Failed to apply row event with 4 columns, originating from a server of version unknown
167 Replica SQL for channel .*: Column 2 of table 'test.t1' cannot be converted from type
168 ;
169 --let $suppress_on_current_connection = 1
170 --source include/suppress_messages.inc
171
172 --source include/rpl_end.inc