mirror of
https://github.com/MariaDB/server.git
synced 2025-02-09 23:24:11 +01:00
![Brandon Nesterenko](/assets/img/avatar_default.png)
This commit makes replicas crash-safe by default by changing the Using_Gtid value to be Slave_Pos on a fresh slave start and after RESET SLAVE is issued. If the primary server does not support GTIDs (i.e., version < 10), the replica will fall back to Using_Gtid=No on slave start and after RESET SLAVE. The following additional informational messages/warnings are added: 1. When Using_Gtid is automatically changed. That is, if RESET SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is inferred to No from a CHANGE MASTER TO given with log coordinates without MASTER_USE_GTID. 2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO is given with log coordinates, yet also specifies MASTER_USE_GTID=Slave_Pos, a warning message is given that the log coordinate options are ignored. Additionally, an MTR macro has been added for RESET SLAVE, reset_slave.inc, which provides modes/options for resetting a slave in log coordinate or gtid modes. When in log coordinates mode, the macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the RESET SLAVE command. When in GTID mode, an extra parameter, reset_slave_keep_gtid_state, can be set to reset or preserve the value of gtid_slave_pos. Reviewed By: =========== Andrei Elkin <andrei.elkin@mariadb.com>
84 lines
2.2 KiB
Text
84 lines
2.2 KiB
Text
include/master-slave.inc
|
|
[connection master]
|
|
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
|
create table t1 (word char(20) not null);
|
|
load data infile '../../std_data/words.dat' into table t1;
|
|
load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1;
|
|
select * from t1 limit 10;
|
|
word
|
|
Aarhus
|
|
Aaron
|
|
Ababa
|
|
aback
|
|
abaft
|
|
abandon
|
|
abandoned
|
|
abandoning
|
|
abandonment
|
|
abandons
|
|
connection slave;
|
|
stop slave;
|
|
connection master;
|
|
create temporary table tmp select * from mysql.global_priv where host="localhost" and user="root";
|
|
set password for root@"localhost" = password('foo');
|
|
connection slave;
|
|
start slave;
|
|
connection master;
|
|
replace into mysql.global_priv select * from tmp;
|
|
Warnings:
|
|
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave
|
|
drop temporary table tmp;
|
|
flush privileges;
|
|
create table t3(n int);
|
|
insert into t3 values(1),(2);
|
|
connection slave;
|
|
select * from t3;
|
|
n
|
|
1
|
|
2
|
|
select sum(length(word)) from t1;
|
|
sum(length(word))
|
|
1022
|
|
connection master;
|
|
drop table t1,t3;
|
|
connection slave;
|
|
connection master;
|
|
create table t1 (n int);
|
|
connection slave;
|
|
connection master;
|
|
reset master;
|
|
connection slave;
|
|
stop slave;
|
|
include/reset_slave.inc
|
|
connection master;
|
|
connection slave;
|
|
lock tables t1 read;
|
|
start slave;
|
|
connection master;
|
|
include/sync_slave_io_with_master.inc
|
|
unlock tables;
|
|
connection master;
|
|
create table t2(id int);
|
|
insert into t2 values(connection_id());
|
|
connection master1;
|
|
create temporary table t3(n int);
|
|
insert into t3 select get_lock('crash_lock%20C', 1) from t2;
|
|
connection master;
|
|
update t1 set n = n + get_lock('crash_lock%20C', 2);
|
|
connection master1;
|
|
select (@id := id) - id from t2;
|
|
(@id := id) - id
|
|
0
|
|
kill @id;
|
|
drop table t2;
|
|
drop temporary table t3;
|
|
connection master;
|
|
Got one of the listed errors
|
|
connection slave;
|
|
include/wait_for_slave_sql_error_and_skip.inc [errno=1927]
|
|
select count(*) from t1;
|
|
count(*)
|
|
5000
|
|
connection master1;
|
|
drop table t1;
|
|
include/rpl_end.inc
|