summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_row_corruption.test
blob: acf3964f0c52496b85d649cbe4c1af64e01e9608 (plain)
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
#
--source include/have_debug.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc

# BUG#11753004: 44360: REPLICATION FAILED 

## assert that we get an error when checking the
## identifiers at the slave (instead of a crash or
## different table being updated)

--let $t1= t1_11753004
--let $t2= t2_11753004
--let $t2_ign= t2_11753004_ign

## test #1: assert that we get an error raised when multiple
##          tables in the same RBR statement are mapped with the
##          same identifier

--eval CREATE TABLE $t1 (c1 INT)
--eval CREATE TABLE $t2 (c1 INT)
--eval INSERT INTO $t1 VALUES (1)
--eval INSERT INTO $t2 VALUES (2)

--sync_slave_with_master
call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*");

# stop the slave and inject corruption
--source include/stop_slave.inc
SET @save_debug= @@global.debug;
SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table";
--source include/start_slave.inc
--connection master
# both tables get mapped to 0 (in a way, simulating scenario 
# originated by BUG#56226)
--eval UPDATE $t1, $t2 SET $t1.c1=3, $t2.c1=4 WHERE $t1.c1=1 OR $t2.c1=2
--connection slave

# wait for error 1593 (ER_SLAVE_FATAL_ERROR)
--let $slave_sql_errno=1593 
--source include/wait_for_slave_sql_error.inc
--source include/stop_slave.inc

# clean up
SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table";
--source include/start_slave.inc
--connection master
--source include/rpl_reset.inc
--eval DROP TABLE $t1, $t2
--sync_slave_with_master

## test #2: assert that ignored tables that may have been mapped
##          with the same identifier are skipped, thus no error
##          is raised.

--connection slave
--source include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table";
--source include/start_slave.inc
--source include/rpl_reset.inc
--connection master
--eval CREATE TABLE $t1 (c1 INT)
--eval CREATE TABLE $t2_ign (c1 INT)
--eval INSERT INTO $t1 VALUES (1)
--eval INSERT INTO $t2_ign VALUES (2)
--eval UPDATE $t1, $t2_ign SET $t1.c1=3, $t2_ign.c1=4 WHERE $t1.c1=1 OR $t2_ign.c1=2

# must not raise error as second table is filtered
--sync_slave_with_master


## test #3: check that BINLOG statements will also raise an
##          error if containing table map events mapping different
##          tables to same table identifier.

CREATE TABLE t1 (c1 INT);
CREATE TABLE t2 (c1 INT);

INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);

# FD event
BINLOG '
SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=
'/*!*/;

#110708 12:21:44 server id 1  end_log_pos 774   Table_map: `test`.`t1` mapped to number 66
# at 774
#110708 12:21:44 server id 1  end_log_pos 815   Table_map: `test`.`t2` mapped to number 67
# at 815
#110708 12:21:44 server id 1  end_log_pos 855   Update_rows: table id 66
# at 855
#110708 12:21:44 server id 1  end_log_pos 895   Update_rows: table id 67 flags: STMT_END_F
SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table";
--error ER_SLAVE_FATAL_ERROR
BINLOG '
SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE=
SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE=
SOgWThgBAAAAKAAAAFcDAAAAAEIAAAAAAAAAAf///gEAAAD+AwAAAA==
SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA==
'/*!*/;


# clean up
DROP TABLE t1,t2;
--connection slave
SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table";
--connection master
--eval DROP TABLE $t1
--eval DROP TABLE $t2_ign
--sync_slave_with_master
SET GLOBAL debug_dbug= @save_debug;

--source include/rpl_end.inc