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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
|
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid= slave_pos;
include/start_slave.inc
connection master;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, 0);
*** Test looking up a lot of different event positions and GTIDs.
CREATE FUNCTION gtid_eq(a VARCHAR(255), b VARCHAR(255)) RETURNS BOOLEAN DETERMINISTIC
BEGIN
DECLARE g VARCHAR(255);
IF a IS NULL OR b IS NULL OR LENGTH(a) != LENGTH(b) THEN
RETURN FALSE;
END IF;
SET a= CONCAT(a, ',');
SET b= CONCAT(',', b, ',');
WHILE LENGTH(a) > 0 DO
SET g= REGEXP_SUBSTR(a, '^[^,]+,');
SET a= SUBSTRING(a, LENGTH(g)+1);
SET b= REPLACE(b, CONCAT(',', g), ',');
END WHILE;
RETURN b = ',';
END //
SET @old_page_size= @@GLOBAL.binlog_gtid_index_page_size;
SET @old_span_min= @@GLOBAL.binlog_gtid_index_span_min;
*** A fair amount of work with default GTID index settings.
*** Testing 200 GTIDs with 50 test connects
connection master;
DELETE FROM t1 WHERE a >= 1000;
FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
CREATE TABLE rand_data(idx INT PRIMARY KEY, domain_id INT, server_id INT)
ENGINE=InnoDB;
INSERT INTO rand_data(idx, domain_id, server_id) VALUES (0, 0, 1);
INSERT INTO rand_data(idx, domain_id, server_id)
SELECT seq,
@tmp:=floor(5*POW(rand(42),2)),
100 + 5*@tmp + floor(5*rand(42))
FROM seq_1_to_200;
SELECT COUNT(*), SUM(domain_id), SUM(server_id) FROM rand_data;
COUNT(*) SUM(domain_id) SUM(server_id)
201 285 21852
CREATE TABLE gtid_data(
idx INT PRIMARY KEY,
gtid VARCHAR(44),
gtid_pos VARCHAR(255),
file VARCHAR(100),
pos INT,
row_count INT,
KEY(file, pos)) ENGINE=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
connection master;
SET @orig_domain_id= @@gtid_domain_id;
SET @orig_server_id= @@server_id;
SET gtid_domain_id= @orig_domain_id;
SET server_id= @orig_server_id;
SELECT COUNT(*) FROM gtid_data;
COUNT(*)
200
*** The result should be empty, otherwise some result is wrong:
SELECT idx, gtid_pos, BINLOG_GTID_POS(file, pos)
FROM gtid_data
WHERE NOT gtid_eq(CONVERT(gtid_pos USING utf8),BINLOG_GTID_POS(file, pos))
ORDER BY idx;
idx gtid_pos BINLOG_GTID_POS(file, pos)
connection slave;
SET @orig_pos= @@GLOBAL.gtid_slave_pos;
SET @orig_t1_limit= (SELECT MAX(a) FROM t1);
*** Now connect the slave to each position in turn, and test that
*** the right amount of data is replicated at each point.
*** Test slave connecting to some GTID positions where the position in
*** the master's binlog is different between the different domains.
*** Revind the slave and test on the same binlog data from the master as before.
connection slave;
SET sql_log_bin= 0;
TRUNCATE gtid_data;
DELETE FROM t1 WHERE a > @orig_t1_limit;
SET sql_log_bin= 1;
SET GLOBAL gtid_slave_pos= @orig_pos;
connection master;
connection slave;
connection master;
DROP TABLE gtid_data, rand_data;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
connection master;
*** A lot of GTIDs with small btree pages to stress the Btree code.
SET GLOBAL binlog_gtid_index_page_size= 64;
SET GLOBAL binlog_gtid_index_span_min= 1;
*** Testing 1000 GTIDs with 50 test connects
connection master;
DELETE FROM t1 WHERE a >= 1000;
FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
CREATE TABLE rand_data(idx INT PRIMARY KEY, domain_id INT, server_id INT)
ENGINE=InnoDB;
INSERT INTO rand_data(idx, domain_id, server_id) VALUES (0, 0, 1);
INSERT INTO rand_data(idx, domain_id, server_id)
SELECT seq,
@tmp:=floor(10*POW(rand(150),2)),
100 + 5*@tmp + floor(5*rand(150))
FROM seq_1_to_1000;
SELECT COUNT(*), SUM(domain_id), SUM(server_id) FROM rand_data;
COUNT(*) SUM(domain_id) SUM(server_id)
1001 2881 116394
CREATE TABLE gtid_data(
idx INT PRIMARY KEY,
gtid VARCHAR(44),
gtid_pos VARCHAR(255),
file VARCHAR(100),
pos INT,
row_count INT,
KEY(file, pos)) ENGINE=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
connection master;
SET @orig_domain_id= @@gtid_domain_id;
SET @orig_server_id= @@server_id;
SET gtid_domain_id= @orig_domain_id;
SET server_id= @orig_server_id;
SELECT COUNT(*) FROM gtid_data;
COUNT(*)
1000
*** The result should be empty, otherwise some result is wrong:
SELECT idx, gtid_pos, BINLOG_GTID_POS(file, pos)
FROM gtid_data
WHERE NOT gtid_eq(CONVERT(gtid_pos USING utf8),BINLOG_GTID_POS(file, pos))
ORDER BY idx;
idx gtid_pos BINLOG_GTID_POS(file, pos)
connection slave;
SET @orig_pos= @@GLOBAL.gtid_slave_pos;
SET @orig_t1_limit= (SELECT MAX(a) FROM t1);
*** Now connect the slave to each position in turn, and test that
*** the right amount of data is replicated at each point.
*** Test slave connecting to some GTID positions where the position in
*** the master's binlog is different between the different domains.
*** Revind the slave and test on the same binlog data from the master as before.
connection slave;
SET sql_log_bin= 0;
TRUNCATE gtid_data;
DELETE FROM t1 WHERE a > @orig_t1_limit;
SET sql_log_bin= 1;
SET GLOBAL gtid_slave_pos= @orig_pos;
connection master;
connection slave;
connection master;
DROP TABLE gtid_data, rand_data;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
connection master;
*** Small page size with sparse index.
SET GLOBAL binlog_gtid_index_page_size= 64;
SET GLOBAL binlog_gtid_index_span_min= 2048;
*** Testing 200 GTIDs with 50 test connects
connection master;
DELETE FROM t1 WHERE a >= 1000;
FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
CREATE TABLE rand_data(idx INT PRIMARY KEY, domain_id INT, server_id INT)
ENGINE=InnoDB;
INSERT INTO rand_data(idx, domain_id, server_id) VALUES (0, 0, 1);
INSERT INTO rand_data(idx, domain_id, server_id)
SELECT seq,
@tmp:=floor(10*POW(rand(666),2)),
100 + 5*@tmp + floor(5*rand(666))
FROM seq_1_to_200;
SELECT COUNT(*), SUM(domain_id), SUM(server_id) FROM rand_data;
COUNT(*) SUM(domain_id) SUM(server_id)
201 599 23410
CREATE TABLE gtid_data(
idx INT PRIMARY KEY,
gtid VARCHAR(44),
gtid_pos VARCHAR(255),
file VARCHAR(100),
pos INT,
row_count INT,
KEY(file, pos)) ENGINE=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
connection master;
SET @orig_domain_id= @@gtid_domain_id;
SET @orig_server_id= @@server_id;
SET gtid_domain_id= @orig_domain_id;
SET server_id= @orig_server_id;
SELECT COUNT(*) FROM gtid_data;
COUNT(*)
200
*** The result should be empty, otherwise some result is wrong:
SELECT idx, gtid_pos, BINLOG_GTID_POS(file, pos)
FROM gtid_data
WHERE NOT gtid_eq(CONVERT(gtid_pos USING utf8),BINLOG_GTID_POS(file, pos))
ORDER BY idx;
idx gtid_pos BINLOG_GTID_POS(file, pos)
connection slave;
SET @orig_pos= @@GLOBAL.gtid_slave_pos;
SET @orig_t1_limit= (SELECT MAX(a) FROM t1);
*** Now connect the slave to each position in turn, and test that
*** the right amount of data is replicated at each point.
*** Test slave connecting to some GTID positions where the position in
*** the master's binlog is different between the different domains.
*** Revind the slave and test on the same binlog data from the master as before.
connection slave;
SET sql_log_bin= 0;
TRUNCATE gtid_data;
DELETE FROM t1 WHERE a > @orig_t1_limit;
SET sql_log_bin= 1;
SET GLOBAL gtid_slave_pos= @orig_pos;
connection master;
connection slave;
connection master;
DROP TABLE gtid_data, rand_data;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
connection master;
*** Medium page size.
SET GLOBAL binlog_gtid_index_page_size= 512;
SET GLOBAL binlog_gtid_index_span_min= 512;
*** Testing 200 GTIDs with 50 test connects
connection master;
DELETE FROM t1 WHERE a >= 1000;
FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
CREATE TABLE rand_data(idx INT PRIMARY KEY, domain_id INT, server_id INT)
ENGINE=InnoDB;
INSERT INTO rand_data(idx, domain_id, server_id) VALUES (0, 0, 1);
INSERT INTO rand_data(idx, domain_id, server_id)
SELECT seq,
@tmp:=floor(10*POW(rand(1024),2)),
100 + 5*@tmp + floor(5*rand(1024))
FROM seq_1_to_200;
SELECT COUNT(*), SUM(domain_id), SUM(server_id) FROM rand_data;
COUNT(*) SUM(domain_id) SUM(server_id)
201 555 23160
CREATE TABLE gtid_data(
idx INT PRIMARY KEY,
gtid VARCHAR(44),
gtid_pos VARCHAR(255),
file VARCHAR(100),
pos INT,
row_count INT,
KEY(file, pos)) ENGINE=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
connection master;
SET @orig_domain_id= @@gtid_domain_id;
SET @orig_server_id= @@server_id;
SET gtid_domain_id= @orig_domain_id;
SET server_id= @orig_server_id;
SELECT COUNT(*) FROM gtid_data;
COUNT(*)
200
*** The result should be empty, otherwise some result is wrong:
SELECT idx, gtid_pos, BINLOG_GTID_POS(file, pos)
FROM gtid_data
WHERE NOT gtid_eq(CONVERT(gtid_pos USING utf8),BINLOG_GTID_POS(file, pos))
ORDER BY idx;
idx gtid_pos BINLOG_GTID_POS(file, pos)
connection slave;
SET @orig_pos= @@GLOBAL.gtid_slave_pos;
SET @orig_t1_limit= (SELECT MAX(a) FROM t1);
*** Now connect the slave to each position in turn, and test that
*** the right amount of data is replicated at each point.
*** Test slave connecting to some GTID positions where the position in
*** the master's binlog is different between the different domains.
*** Revind the slave and test on the same binlog data from the master as before.
connection slave;
SET sql_log_bin= 0;
TRUNCATE gtid_data;
DELETE FROM t1 WHERE a > @orig_t1_limit;
SET sql_log_bin= 1;
SET GLOBAL gtid_slave_pos= @orig_pos;
connection master;
connection slave;
connection master;
DROP TABLE gtid_data, rand_data;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
connection master;
*** Large page size.
SET GLOBAL binlog_gtid_index_page_size= 16384;
SET GLOBAL binlog_gtid_index_span_min= 1;
*** Testing 200 GTIDs with 50 test connects
connection master;
DELETE FROM t1 WHERE a >= 1000;
FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
CREATE TABLE rand_data(idx INT PRIMARY KEY, domain_id INT, server_id INT)
ENGINE=InnoDB;
INSERT INTO rand_data(idx, domain_id, server_id) VALUES (0, 0, 1);
INSERT INTO rand_data(idx, domain_id, server_id)
SELECT seq,
@tmp:=floor(10*POW(rand(12345),2)),
100 + 5*@tmp + floor(5*rand(12345))
FROM seq_1_to_200;
SELECT COUNT(*), SUM(domain_id), SUM(server_id) FROM rand_data;
COUNT(*) SUM(domain_id) SUM(server_id)
201 571 23252
CREATE TABLE gtid_data(
idx INT PRIMARY KEY,
gtid VARCHAR(44),
gtid_pos VARCHAR(255),
file VARCHAR(100),
pos INT,
row_count INT,
KEY(file, pos)) ENGINE=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
connection master;
SET @orig_domain_id= @@gtid_domain_id;
SET @orig_server_id= @@server_id;
SET gtid_domain_id= @orig_domain_id;
SET server_id= @orig_server_id;
SELECT COUNT(*) FROM gtid_data;
COUNT(*)
200
*** The result should be empty, otherwise some result is wrong:
SELECT idx, gtid_pos, BINLOG_GTID_POS(file, pos)
FROM gtid_data
WHERE NOT gtid_eq(CONVERT(gtid_pos USING utf8),BINLOG_GTID_POS(file, pos))
ORDER BY idx;
idx gtid_pos BINLOG_GTID_POS(file, pos)
connection slave;
SET @orig_pos= @@GLOBAL.gtid_slave_pos;
SET @orig_t1_limit= (SELECT MAX(a) FROM t1);
*** Now connect the slave to each position in turn, and test that
*** the right amount of data is replicated at each point.
*** Test slave connecting to some GTID positions where the position in
*** the master's binlog is different between the different domains.
*** Revind the slave and test on the same binlog data from the master as before.
connection slave;
SET sql_log_bin= 0;
TRUNCATE gtid_data;
DELETE FROM t1 WHERE a > @orig_t1_limit;
SET sql_log_bin= 1;
SET GLOBAL gtid_slave_pos= @orig_pos;
connection master;
connection slave;
connection master;
DROP TABLE gtid_data, rand_data;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
connection master;
connection master;
SET GLOBAL binlog_gtid_index_page_size= @old_page_size;
SET GLOBAL binlog_gtid_index_span_min= @old_span_min;
DROP TABLE t1;
DROP FUNCTION gtid_eq;
include/rpl_end.inc
|