Skip to content

Commit 7f2cfa8

Browse files
MDEV-8874 Replication filters configured in my.cnf are ignored if slave reset and reconfigured
Don't delete the rpl_filter on RESET SLAVE.
1 parent aa55d93 commit 7f2cfa8

File tree

5 files changed

+287
-3
lines changed

5 files changed

+287
-3
lines changed

mysql-test/lib/My/Config.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,13 @@ sub new {
327327
# Skip comment
328328
next;
329329
}
330-
330+
# Correctly process Replication Filter when they are defined
331+
# with connection name.
332+
elsif ( $line =~ /^([\w]+.[\w]+)\s*=\s*(.*)\s*/){
333+
my $option= $1;
334+
my $value= $2;
335+
$self->insert($group_name, $option, $value);
336+
}
331337
else {
332338
croak "Unexpected line '$line' found in '$path'";
333339
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
!include my.cnf
2+
3+
[mysqld.1]
4+
log-bin
5+
log-slave-updates
6+
7+
[mysqld.2]
8+
log-bin
9+
log-slave-updates
10+
11+
[mysqld.3]
12+
log-bin
13+
log-slave-updates
14+
15+
[mysqld.4]
16+
server-id=4
17+
log-bin=server4-bin
18+
log-slave-updates
19+
m1.replicate_ignore_table='a.t1'
20+
m2.replicate_ignore_table='b.t1'
21+
replicate_ignore_table='c.t1'
22+
23+
[ENV]
24+
SERVER_MYPORT_4= @mysqld.4.port
25+
SERVER_MYSOCK_4= @mysqld.4.socket
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
create database a;
2+
use a;
3+
create table t1(a int);
4+
insert into t1 values(1);
5+
create table t2(a int);
6+
insert into t2 values(1);
7+
create database b;
8+
use b;
9+
create table t1(a int);
10+
insert into t1 values(1);
11+
create table t2(a int);
12+
insert into t2 values(1);
13+
create database c;
14+
use c;
15+
create table t1(a int);
16+
insert into t1 values(1);
17+
create table t2(a int);
18+
insert into t2 values(1);
19+
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root';
20+
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root';
21+
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root';
22+
start all slaves;
23+
set default_master_connection = 'm1';
24+
include/wait_for_slave_to_start.inc
25+
set default_master_connection = 'm2';
26+
include/wait_for_slave_to_start.inc
27+
set default_master_connection = '';
28+
include/wait_for_slave_to_start.inc
29+
select @@global.'m1'.replicate_ignore_table;
30+
@@global.'m1'.replicate_ignore_table
31+
a.t1
32+
select @@global.'m2'.replicate_ignore_table;
33+
@@global.'m2'.replicate_ignore_table
34+
b.t1
35+
select @@global.replicate_ignore_table;
36+
@@global.replicate_ignore_table
37+
c.t1
38+
use a;
39+
#No t1 table
40+
show tables;
41+
Tables_in_a
42+
t2
43+
use b;
44+
#No t1 table
45+
show tables;
46+
Tables_in_b
47+
t2
48+
use c;
49+
#No t1 table
50+
show tables;
51+
Tables_in_c
52+
t2
53+
#TEST
54+
STOP ALL SLAVES;
55+
Warnings:
56+
Note 1938 SLAVE 'm2' stopped
57+
Note 1938 SLAVE '' stopped
58+
Note 1938 SLAVE 'm1' stopped
59+
RESET SLAVE 'm1' ALL ;
60+
RESET SLAVE 'm2' ALL ;
61+
RESET SLAVE ALL ;
62+
drop database a;
63+
drop database b;
64+
drop database c;
65+
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root';
66+
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root';
67+
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root';
68+
start all slaves;
69+
Warnings:
70+
Note 1937 SLAVE 'm2' started
71+
Note 1937 SLAVE '' started
72+
Note 1937 SLAVE 'm1' started
73+
set default_master_connection = 'm1';
74+
include/wait_for_slave_to_start.inc
75+
set default_master_connection = 'm2';
76+
include/wait_for_slave_to_start.inc
77+
set default_master_connection = '';
78+
include/wait_for_slave_to_start.inc
79+
#Replication Filter should be intact (t1 still not replicated)
80+
select @@global.'m1'.replicate_ignore_table;
81+
@@global.'m1'.replicate_ignore_table
82+
a.t1
83+
select @@global.'m2'.replicate_ignore_table;
84+
@@global.'m2'.replicate_ignore_table
85+
b.t1
86+
select @@global.replicate_ignore_table;
87+
@@global.replicate_ignore_table
88+
c.t1
89+
use a;
90+
#No t1 table
91+
show tables;
92+
Tables_in_a
93+
t2
94+
use b;
95+
#No t1 table
96+
show tables;
97+
Tables_in_b
98+
t2
99+
use c;
100+
#No t1 table
101+
show tables;
102+
Tables_in_c
103+
t2
104+
#CleanUp
105+
drop database a;
106+
drop database b;
107+
drop database c;
108+
stop all slaves;
109+
SET default_master_connection = "m1";
110+
include/wait_for_slave_to_stop.inc
111+
SET default_master_connection = "m2";
112+
include/wait_for_slave_to_stop.inc
113+
SET default_master_connection = "";
114+
include/wait_for_slave_to_stop.inc
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
--source include/not_embedded.inc
2+
--source include/have_innodb.inc
3+
--source include/have_debug.inc
4+
# MDEV-8874
5+
# In Named Master slave connection if we do reset slave 'connection_name' ALL and then
6+
# if we reconnect slave, replication filters are ignored.
7+
# This patch fixes this issue.
8+
--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1)
9+
--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2)
10+
--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3)
11+
--connect (server_4,127.0.0.1,root,,,$SERVER_MYPORT_4)
12+
13+
--connection server_1
14+
create database a;
15+
use a;
16+
create table t1(a int);
17+
insert into t1 values(1);
18+
create table t2(a int);
19+
insert into t2 values(1);
20+
--save_master_pos
21+
22+
--connection server_2
23+
create database b;
24+
use b;
25+
create table t1(a int);
26+
insert into t1 values(1);
27+
create table t2(a int);
28+
insert into t2 values(1);
29+
--save_master_pos
30+
31+
--connection server_3
32+
create database c;
33+
use c;
34+
create table t1(a int);
35+
insert into t1 values(1);
36+
create table t2(a int);
37+
insert into t2 values(1);
38+
--save_master_pos
39+
40+
--connection server_4
41+
--disable_warnings
42+
--replace_result $SERVER_MYPORT_1 MYPORT_1
43+
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root';
44+
--replace_result $SERVER_MYPORT_2 MYPORT_2
45+
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root';
46+
--replace_result $SERVER_MYPORT_3 MYPORT_3
47+
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root';
48+
start all slaves;
49+
set default_master_connection = 'm1';
50+
--source include/wait_for_slave_to_start.inc
51+
set default_master_connection = 'm2';
52+
--source include/wait_for_slave_to_start.inc
53+
set default_master_connection = '';
54+
--source include/wait_for_slave_to_start.inc
55+
select @@global.'m1'.replicate_ignore_table;
56+
select @@global.'m2'.replicate_ignore_table;
57+
select @@global.replicate_ignore_table;
58+
59+
--enable_warnings
60+
--sync_with_master 0,'m1'
61+
--sync_with_master 0,'m2'
62+
--sync_with_master 0,''
63+
use a;
64+
--echo #No t1 table
65+
show tables;
66+
use b;
67+
--echo #No t1 table
68+
show tables;
69+
use c;
70+
--echo #No t1 table
71+
show tables;
72+
--echo #TEST
73+
STOP ALL SLAVES;
74+
RESET SLAVE 'm1' ALL ;
75+
RESET SLAVE 'm2' ALL ;
76+
RESET SLAVE ALL ;
77+
drop database a;
78+
drop database b;
79+
drop database c;
80+
--replace_result $SERVER_MYPORT_1 MYPORT_1
81+
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root';
82+
--replace_result $SERVER_MYPORT_2 MYPORT_2
83+
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root';
84+
--replace_result $SERVER_MYPORT_3 MYPORT_3
85+
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root';
86+
start all slaves;
87+
set default_master_connection = 'm1';
88+
--source include/wait_for_slave_to_start.inc
89+
set default_master_connection = 'm2';
90+
--source include/wait_for_slave_to_start.inc
91+
set default_master_connection = '';
92+
--source include/wait_for_slave_to_start.inc
93+
--sync_with_master 0,'m1'
94+
--sync_with_master 0,'m2'
95+
--sync_with_master 0,''
96+
97+
--echo #Replication Filter should be intact (t1 still not replicated)
98+
select @@global.'m1'.replicate_ignore_table;
99+
select @@global.'m2'.replicate_ignore_table;
100+
select @@global.replicate_ignore_table;
101+
use a;
102+
--echo #No t1 table
103+
show tables;
104+
use b;
105+
--echo #No t1 table
106+
show tables;
107+
use c;
108+
--echo #No t1 table
109+
show tables;
110+
111+
112+
#--echo #restart the server
113+
#--source include/restart_mysqld.inc
114+
115+
116+
--echo #CleanUp
117+
--connection server_1
118+
drop database a;
119+
--save_master_pos
120+
121+
--connection server_2
122+
drop database b;
123+
--save_master_pos
124+
125+
--connection server_3
126+
drop database c;
127+
--save_master_pos
128+
129+
--connection server_4
130+
--sync_with_master 0,'m1'
131+
--sync_with_master 0,'m2'
132+
--sync_with_master 0,''
133+
--disable_warnings
134+
stop all slaves;
135+
--enable_warnings
136+
SET default_master_connection = "m1";
137+
--source include/wait_for_slave_to_stop.inc
138+
SET default_master_connection = "m2";
139+
--source include/wait_for_slave_to_stop.inc
140+
SET default_master_connection = "";
141+
--source include/wait_for_slave_to_stop.inc

sql/rpl_mi.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ Master_info::~Master_info()
122122
*/
123123
if (strncmp(connection_name.str, STRING_WITH_LEN("wsrep")))
124124
#endif
125-
rpl_filters.delete_element(connection_name.str, connection_name.length,
126-
(void (*)(const char*, uchar*)) free_rpl_filter);
127125
my_free(connection_name.str);
128126
delete_dynamic(&ignore_server_ids);
129127
mysql_mutex_destroy(&run_lock);

0 commit comments

Comments
 (0)