1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-9544 FLUSH [RELAY] LOGS does not rotate logs for a named slave

Problem:- In the case of multisource replication/named slave
when we run "FLUSH LOGS" , it does not flush logs.

Solution:- A new function Master_info_index->flush_all_relay_logs()
is created which will rotate relay logs for all named slave.
This will be called in reload_acl_and_cache function when
connection_name.length == 0
This commit is contained in:
Sachin Setiya
2017-06-05 13:10:24 +05:30
parent 112b21da37
commit da61107fc8
6 changed files with 274 additions and 3 deletions

View File

@ -0,0 +1,22 @@
!include my.cnf
[mysqld.1]
log-bin
log-slave-updates
[mysqld.2]
log-bin
log-slave-updates
[mysqld.3]
log-bin
log-slave-updates
[mysqld.4]
server-id=4
log-bin=server4-bin
log-slave-updates
[ENV]
SERVER_MYPORT_4= @mysqld.4.port
SERVER_MYSOCK_4= @mysqld.4.socket

View File

@ -0,0 +1,78 @@
create database a;
use a;
create table t1(a int);
insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
create database b;
use b;
create table t1(a int);
insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
create database c;
use c;
create table t1(a int);
insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root';
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root';
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root';
start all slaves;
set default_master_connection = 'm1';
include/wait_for_slave_to_start.inc
set default_master_connection = 'm2';
include/wait_for_slave_to_start.inc
set default_master_connection = '';
include/wait_for_slave_to_start.inc
use a;
show tables;
Tables_in_a
t1
t2
use b;
show tables;
Tables_in_b
t1
t2
use c;
show tables;
Tables_in_c
t1
t2
#TEST
SET default_master_connection = "m1";
SET default_master_connection = "m2";
SET default_master_connection = "";
flush logs;
SET default_master_connection = "m1";
#log Rotated
mysqld-relay-bin.000002
mysqld-relay-bin.000003
mysqld-relay-bin.index
SET default_master_connection = "m2";
#log Rotated
mysqld-relay-bin-m1.000002
mysqld-relay-bin-m1.000003
mysqld-relay-bin-m1.index
SET default_master_connection = "";
#log Rotated
mysqld-relay-bin-m2.000002
mysqld-relay-bin-m2.000003
mysqld-relay-bin-m2.index
#CleanUp
drop database a;
drop database b;
drop database c;
stop all slaves;
Warnings:
Note 1938 SLAVE 'm2' stopped
Note 1938 SLAVE '' stopped
Note 1938 SLAVE 'm1' stopped
SET default_master_connection = "m1";
include/wait_for_slave_to_stop.inc
SET default_master_connection = "m2";
include/wait_for_slave_to_stop.inc
SET default_master_connection = "";
include/wait_for_slave_to_stop.inc

View File

@ -0,0 +1,116 @@
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_debug.inc
--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1)
--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2)
--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3)
--connect (server_4,127.0.0.1,root,,,$SERVER_MYPORT_4)
--connection server_1
create database a;
use a;
create table t1(a int);
insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
--save_master_pos
--connection server_2
create database b;
use b;
create table t1(a int);
insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
--save_master_pos
--connection server_3
create database c;
use c;
create table t1(a int);
insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
--save_master_pos
--connection server_4
--disable_warnings
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root';
--replace_result $SERVER_MYPORT_2 MYPORT_2
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root';
--replace_result $SERVER_MYPORT_3 MYPORT_3
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root';
start all slaves;
set default_master_connection = 'm1';
--source include/wait_for_slave_to_start.inc
set default_master_connection = 'm2';
--source include/wait_for_slave_to_start.inc
set default_master_connection = '';
--source include/wait_for_slave_to_start.inc
--enable_warnings
--sync_with_master 0,'m1'
--sync_with_master 0,'m2'
--sync_with_master 0,''
use a;
show tables;
use b;
show tables;
use c;
show tables;
--echo #TEST
SET default_master_connection = "m1";
--let $old_m1 = query_get_value("show relaylog events;", "Log_name",1)
SET default_master_connection = "m2";
--let $old_m2 = query_get_value("show relaylog events;", "Log_name",1)
SET default_master_connection = "";
--let $old__ = query_get_value("show relaylog events;", "Log_name",1)
flush logs;
--sleep 2
--let $MYSQLD_DATADIR = `select @@datadir`
SET default_master_connection = "m1";
--let $new_m1 = query_get_value("show relaylog events;", "Log_name",1)
--if ($new_m1 != $old_m1) {
--echo #log Rotated
--exec ls $MYSQLD_DATADIR | grep "mysqld-relay-bin\."
}
SET default_master_connection = "m2";
--let $new_m2 = query_get_value("show relaylog events;", "Log_name",1)
--if ($new_m2 != $old_m2) {
--echo #log Rotated
--exec ls $MYSQLD_DATADIR | grep "mysqld-relay-bin-m1"
}
SET default_master_connection = "";
--let $new__ = query_get_value("show relaylog events;", "Log_name",1)
--if ($new__ != $old__) {
--echo #log Rotated
--exec ls $MYSQLD_DATADIR | grep "mysqld-relay-bin-m2"
}
--echo #CleanUp
--connection server_1
drop database a;
--save_master_pos
--connection server_2
drop database b;
--save_master_pos
--connection server_3
drop database c;
--save_master_pos
--connection server_4
--sync_with_master 0,'m1'
--sync_with_master 0,'m2'
--sync_with_master 0,''
stop all slaves;
SET default_master_connection = "m1";
--source include/wait_for_slave_to_stop.inc
SET default_master_connection = "m2";
--source include/wait_for_slave_to_stop.inc
SET default_master_connection = "";
--source include/wait_for_slave_to_stop.inc