Debian Codegraph @

mysql-test/suite/s3/replication_partition.test

raw
1 --source include/have_s3.inc
2 --source include/have_partition.inc
3 --source include/have_binlog_format_mixed.inc
4 --source include/have_innodb.inc
5 --source include/have_sequence.inc
6 --source include/master-slave.inc
7 --source create_database.inc
8
9 sync_slave_with_master;
10
11 if (`select @@s3_slave_ignore_updates <> 1`)
12 {
13 die "Slave is not configured with s3-slave-ignore-updates=1";
14 }
15
16 let $MYSQLD_DATADIR= `select @@datadir`;
17 --replace_result $database database
18 --eval use $database
19 connection master;
20
21 --echo #
22 --echo # Check replication of parititioned S3 tables
23 --echo #
24
25 CREATE TABLE t1 (
26 c1 INT DEFAULT NULL
27 ) ENGINE=Aria
28 PARTITION BY HASH (c1)
29 PARTITIONS 3;
30 INSERT INTO t1 VALUE (1), (2), (101), (102), (201), (202);
31 ALTER TABLE t1 ENGINE=S3;
32 sync_slave_with_master;
33 connection master;
34 ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
35 select sum(c1) from t1;
36 sync_slave_with_master;
37 connection master;
38 ALTER TABLE t1 ADD COLUMN c INT;
39 select sum(c1) from t1;
40 sync_slave_with_master;
41 show create table t1;
42 select sum(c1) from t1;
43 connection master;
44 drop table t1;
45
46 --echo #
47 --echo # Checking that the slave is keeping in sync with changed partitions
48 --echo #
49
50 CREATE TABLE t1 (
51 c1 int primary key,
52 c2 int DEFAULT NULL
53 ) ENGINE=InnoDB
54 PARTITION BY RANGE (c1)
55 (PARTITION p1 VALUES LESS THAN (200),
56 PARTITION p2 VALUES LESS THAN (300),
57 PARTITION p3 VALUES LESS THAN (400));
58 insert into t1 select seq*100,seq*100 from seq_1_to_3;
59 alter table t1 engine=S3;
60 show create table t1;
61
62 sync_slave_with_master;
63 select sum(c1) from t1;
64 --file_exists $MYSQLD_DATADIR/$database/t1.frm
65 --file_exists $MYSQLD_DATADIR/$database/t1.par
66 stop slave;
67 connection master;
68 ALTER TABLE t1 ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
69 connection slave;
70 show create table t1;
71 select sum(c1) from t1;
72 start slave;
73 connection master;
74 sync_slave_with_master;
75 select sum(c1)+0 from t1;
76 stop slave;
77
78 # Ensure the slave is using the new table
79 show create table t1;
80
81 connection master;
82 drop table t1;
83 connection slave;
84 --file_exists $MYSQLD_DATADIR/$database/t1.par
85 --replace_result $database database
86 --error ER_NO_SUCH_TABLE
87 select sum(c1) from t1;
88 --error 1
89 --file_exists $MYSQLD_DATADIR/$database/t1.par
90 start slave;
91 connection master;
92 sync_slave_with_master;
93 connection master;
94
95 --echo #
96 --echo # Check altering partitioned table to S3 and back
97 --echo # Checks also rename partitoned table and drop partition
98 --echo #
99
100 CREATE TABLE t2 (
101 c1 int primary key,
102 c2 int DEFAULT NULL
103 ) ENGINE=InnoDB
104 PARTITION BY RANGE (c1)
105 (PARTITION p1 VALUES LESS THAN (200),
106 PARTITION p2 VALUES LESS THAN (300),
107 PARTITION p3 VALUES LESS THAN (400));
108 insert into t2 select seq*100,seq*100 from seq_1_to_3;
109 alter table t2 engine=S3;
110 rename table t2 to t1;
111 alter table t1 drop partition p1;
112 sync_slave_with_master;
113 select sum(c1) from t1;
114 connection master;
115 alter table t1 engine=innodb;
116 sync_slave_with_master;
117 select sum(c1) from t1;
118 connection master;
119 drop table t1;
120
121 --echo #
122 --echo # Check that slaves ignores changes to S3 tables.
123 --echo #
124
125 connection master;
126 CREATE TABLE t1 (
127 c1 int primary key,
128 c2 int DEFAULT NULL
129 ) ENGINE=InnoDB
130 PARTITION BY RANGE (c1)
131 (PARTITION p1 VALUES LESS THAN (200),
132 PARTITION p2 VALUES LESS THAN (300),
133 PARTITION p3 VALUES LESS THAN (400));
134 insert into t1 select seq*100,seq*100 from seq_1_to_3;
135 create table t2 like t1;
136 alter table t2 remove partitioning;
137 insert into t2 values (450,450);
138 sync_slave_with_master;
139 stop slave;
140 connection master;
141 alter table t1 engine=s3;
142 alter table t2 engine=s3;
143 ALTER TABLE t1 ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
144 alter table t1 exchange partition p4 with table t2;
145 select count(*) from t1;
146 drop table t1,t2;
147 connection slave;
148 start slave;
149 connection master;
150 sync_slave_with_master;
151 --replace_result $database database
152 --error ER_NO_SUCH_TABLE
153 select sum(c1) from t1;
154 connection master;
155
156 --echo #
157 --echo # Check slave binary log
158 --echo #
159
160 sync_slave_with_master;
161 --let $binlog_database=$database
162 --source include/show_binlog_events.inc
163 connection master;
164
165 --echo #
166 --echo # clean up
167 --echo #
168 --source drop_database.inc
169 sync_slave_with_master;
170 --source include/rpl_end.inc