Debian Codegraph @

mysql-test/suite/rpl/t/rpl_gipk_on_source_minimal_binlog_row_image.test

raw
1 # === Purpose ===
2 #
3 # This test checks that when binlog_row_image is set to minimal and the source has tables with GIPKs
4 # and the replica does not, updates/deletes on those tables will fail as the GIPK is used to identify the
5 # rows.
6 #
7 # ==== Requirements ====
8 #
9 # R1. If binlog_row_image is set to a value different from full it might prevent a replica table without a key
10 # from locating rows to be updated as the source uses its GIPK to identify those rows.
11 #
12 # === Implementation ====
13 #
14 # 0. This test requires the source to execute its transactions with
15 # binlog_row_image = minimal
16 # 1. Enable the generation of GIPKs in the source
17 # With the binary log temporarily disabled, create table t1
18 # Create the same table on the replica
19 # Add a row to the table on the source
20 # 2. Update the row on the source
21 # Check the replica applier fails as it cannot locate the key
22 # 3. Cleanup
23 #
24 # === References ===
25 #
26 # Wl#14639: Row-based replication between tables that differ in the existence of a generated invisible primary key
27 #
28
29 --source include/have_binlog_format_row.inc
30 --source include/master-slave.inc
31
32 --echo
33 --echo ##################################################
34 --echo # 0. This test requires the source to execute its transactions with
35 --echo # binlog_row_image = minimal
36
37 --source include/rpl_connection_master.inc
38
39 SET @@SESSION.binlog_row_image = 'MINIMAL';
40
41 --echo
42 --echo ##################################################
43 --echo # 1. Enable the generation of GIPKs in the source
44 --echo # With the binary log temporarily disabled, create table t1
45 --echo # Create the same table on the replica
46 --echo # Add a row to the table on the source
47
48 --source include/rpl_connection_slave.inc
49
50 CREATE TABLE t1(f1 INT, f2 INT);
51
52 --source include/rpl_connection_master.inc
53
54 # Set at the session level, so no restore needed for MTR
55 SET SESSION sql_generate_invisible_primary_key = ON;
56
57 --source include/disable_binlog.inc
58 CREATE TABLE t1(f1 INT, f2 INT);
59 --source include/restore_binlog.inc
60
61 SET SESSION sql_generate_invisible_primary_key = OFF;
62
63 INSERT INTO t1 VALUES (1, 1);
64
65 --source include/sync_slave_sql_with_master.inc
66
67 --let $row_count= `SELECT COUNT(*) FROM t1;`
68 --let $assert_text= The table t1 contains the inserted row
69 --let $assert_cond= $row_count = 1
70 --source include/assert.inc
71
72 --echo
73 --echo ##################################################
74 --echo # 2. Update the row on the source
75 --echo # Check the replica applier fails as it cannot locate the key
76
77 --source include/rpl_connection_master.inc
78
79 UPDATE t1 SET t1.f1 = 3 WHERE t1.f1=1;
80
81 --source include/rpl_connection_slave.inc
82
83 --let $slave_sql_errno= convert_error(ER_KEY_NOT_FOUND)
84 --source include/wait_for_slave_sql_error.inc
85
86 --let $row_count= `SELECT COUNT(*) FROM t1 WHERE t1.f1=3;`
87 --let $assert_text= The table t1 contains no rows on the replica
88 --let $assert_cond= $row_count = 0
89 --source include/assert.inc
90
91 --echo
92 --echo ##################################################
93 --echo # 3. Cleanup
94
95 --source include/rpl_connection_master.inc
96
97 RESET MASTER;
98
99 --source include/rpl_connection_slave.inc
100
101 --source include/stop_slave.inc
102 --source include/rpl_reset_slave.inc
103 RESET MASTER;
104 --source include/start_slave.inc
105
106 let $messages =
107 Replica SQL for channel .*: Worker .* failed executing transaction .* at source log master-bin.000001, end_log_pos .* Could not execute Update_rows event on table test
108 Replica SQL for channel .*: ... The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state.
109 Replica SQL for channel .*: Could not execute Update_rows event on table test.t1
110 Replica: Can.* find record in 't1'
111 ;
112 --let $suppress_on_current_connection = 1
113 --source include/suppress_messages.inc
114
115 --source include/rpl_connection_master.inc
116
117 DROP TABLE t1;
118
119 --source include/rpl_end.inc