mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Incorrect statements binlogged on slave with do_domain_ids=(...)
In domain ID based filtering, a flag is used to filter-out the events that belong to a particular domain. This flag gets set when IO thread receives a GTID_EVENT for the domain on filter list and its reset at the last event in the GTID group. The resetting, however, was wrongly done before the decision to write/filter the event from relay log is made. As a result, the last event in the group will always pass through the filter. Fixed by deferring the reset logic. Also added a test case.
This commit is contained in:
parent
836275bb20
commit
f47124c9ef
4 changed files with 188 additions and 16 deletions
73
mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result
Normal file
73
mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result
Normal file
|
@ -0,0 +1,73 @@
|
|||
include/rpl_init.inc [topology=1->2->3]
|
||||
include/stop_slave.inc
|
||||
CHANGE MASTER TO
|
||||
MASTER_USE_GTID = SLAVE_POS, IGNORE_SERVER_IDS = (2,3);
|
||||
CHANGE MASTER "M_3" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = SERVER_MYPORT_3,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (1,2);
|
||||
START ALL SLAVES;
|
||||
Warnings:
|
||||
Note 1937 SLAVE 'M_3' started
|
||||
Note 1937 SLAVE '' started
|
||||
include/stop_slave.inc
|
||||
CHANGE MASTER "M_1" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = MASTER_MYPORT,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (2,3);
|
||||
CHANGE MASTER TO
|
||||
MASTER_USE_GTID = SLAVE_POS, IGNORE_SERVER_IDS = (1,3);
|
||||
START ALL SLAVES;
|
||||
Warnings:
|
||||
Note 1937 SLAVE 'M_1' started
|
||||
Note 1937 SLAVE '' started
|
||||
CHANGE MASTER "M_2" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = SLAVE_MYPORT,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (1,3);
|
||||
CHANGE MASTER "M_3" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = SERVER_MYPORT_3,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (1,2);
|
||||
START ALL SLAVES;
|
||||
Warnings:
|
||||
Note 1937 SLAVE 'M_3' started
|
||||
Note 1937 SLAVE 'M_2' started
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (1, "m1");
|
||||
INSERT INTO t1 VALUES (2, "m2"), (3, "m3"), (4, "m4");
|
||||
include/save_master_gtid.inc
|
||||
include/sync_with_master_gtid.inc
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
a b
|
||||
1 m1
|
||||
2 m2
|
||||
3 m3
|
||||
4 m4
|
||||
include/sync_with_master_gtid.inc
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
a b
|
||||
1 m1
|
||||
2 m2
|
||||
3 m3
|
||||
4 m4
|
||||
# Cleanup
|
||||
DROP TABLE t1;
|
||||
include/save_master_gtid.inc
|
||||
include/sync_with_master_gtid.inc
|
||||
include/sync_with_master_gtid.inc
|
||||
STOP SLAVE "M_3";
|
||||
RESET SLAVE "M_3" ALL;
|
||||
STOP SLAVE "M_1";
|
||||
RESET SLAVE "M_1" ALL;
|
||||
STOP SLAVE "M_2";
|
||||
RESET SLAVE "M_2" ALL;
|
||||
STOP SLAVE "M_3";
|
||||
RESET SLAVE "M_3" ALL;
|
||||
include/sync_with_master_gtid.inc
|
||||
STOP SLAVE;
|
||||
CHANGE MASTER TO MASTER_USE_GTID = NO, IGNORE_SERVER_IDS = ();
|
||||
include/sync_with_master_gtid.inc
|
||||
STOP SLAVE;
|
||||
CHANGE MASTER TO MASTER_USE_GTID = NO, IGNORE_SERVER_IDS = ();
|
||||
# End of test.
|
20
mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf
Normal file
20
mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf
Normal file
|
@ -0,0 +1,20 @@
|
|||
!include ../my.cnf
|
||||
|
||||
[mysqld.1]
|
||||
log-slave-updates
|
||||
loose-innodb
|
||||
gtid_domain_id=1
|
||||
|
||||
[mysqld.2]
|
||||
log-slave-updates
|
||||
loose-innodb
|
||||
gtid_domain_id=2
|
||||
|
||||
[mysqld.3]
|
||||
log-slave-updates
|
||||
loose-innodb
|
||||
gtid_domain_id=3
|
||||
|
||||
[ENV]
|
||||
SERVER_MYPORT_3= @mysqld.3.port
|
||||
SERVER_MYSOCK_3= @mysqld.3.socket
|
92
mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test
Normal file
92
mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test
Normal file
|
@ -0,0 +1,92 @@
|
|||
--source include/have_innodb.inc
|
||||
--let $rpl_topology=1->2->3
|
||||
--source include/rpl_init.inc
|
||||
|
||||
--connection server_2
|
||||
--source include/stop_slave.inc
|
||||
eval CHANGE MASTER TO
|
||||
MASTER_USE_GTID = SLAVE_POS, IGNORE_SERVER_IDS = (2,3);
|
||||
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
|
||||
eval CHANGE MASTER "M_3" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = $SERVER_MYPORT_3,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (1,2);
|
||||
START ALL SLAVES;
|
||||
|
||||
--connection server_3
|
||||
--source include/stop_slave.inc
|
||||
--replace_result $MASTER_MYPORT MASTER_MYPORT
|
||||
eval CHANGE MASTER "M_1" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = $MASTER_MYPORT,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (2,3);
|
||||
eval CHANGE MASTER TO
|
||||
MASTER_USE_GTID = SLAVE_POS, IGNORE_SERVER_IDS = (1,3);
|
||||
START ALL SLAVES;
|
||||
|
||||
--connection server_1
|
||||
--replace_result $SLAVE_MYPORT SLAVE_MYPORT
|
||||
eval CHANGE MASTER "M_2" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = $SLAVE_MYPORT,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (1,3);
|
||||
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
|
||||
eval CHANGE MASTER "M_3" TO
|
||||
MASTER_HOST = "127.0.0.1", MASTER_PORT = $SERVER_MYPORT_3,
|
||||
MASTER_USER = "root", MASTER_USE_GTID = SLAVE_POS,
|
||||
IGNORE_SERVER_IDS = (1,2);
|
||||
START ALL SLAVES;
|
||||
|
||||
connection server_1;
|
||||
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (1, "m1");
|
||||
INSERT INTO t1 VALUES (2, "m2"), (3, "m3"), (4, "m4");
|
||||
|
||||
--source include/save_master_gtid.inc
|
||||
|
||||
connection server_2;
|
||||
--source include/sync_with_master_gtid.inc
|
||||
let $wait_condition=SELECT COUNT(*)=4 FROM t1;
|
||||
--source include/wait_condition.inc
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
connection server_3;
|
||||
--source include/sync_with_master_gtid.inc
|
||||
--source include/wait_condition.inc
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
--echo # Cleanup
|
||||
--connection server_1
|
||||
DROP TABLE t1;
|
||||
--source include/save_master_gtid.inc
|
||||
--connection server_2
|
||||
--source include/sync_with_master_gtid.inc
|
||||
--connection server_3
|
||||
--source include/sync_with_master_gtid.inc
|
||||
|
||||
--connection server_2
|
||||
STOP SLAVE "M_3";
|
||||
RESET SLAVE "M_3" ALL;
|
||||
|
||||
--connection server_3
|
||||
STOP SLAVE "M_1";
|
||||
RESET SLAVE "M_1" ALL;
|
||||
|
||||
--connection server_1
|
||||
STOP SLAVE "M_2";
|
||||
RESET SLAVE "M_2" ALL;
|
||||
STOP SLAVE "M_3";
|
||||
RESET SLAVE "M_3" ALL;
|
||||
|
||||
--connection server_2
|
||||
--source include/sync_with_master_gtid.inc
|
||||
STOP SLAVE;
|
||||
CHANGE MASTER TO MASTER_USE_GTID = NO, IGNORE_SERVER_IDS = ();
|
||||
|
||||
--connection server_3
|
||||
--source include/sync_with_master_gtid.inc
|
||||
STOP SLAVE;
|
||||
CHANGE MASTER TO MASTER_USE_GTID = NO, IGNORE_SERVER_IDS = ();
|
||||
|
||||
--echo # End of test.
|
19
sql/slave.cc
19
sql/slave.cc
|
@ -5875,22 +5875,6 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
|
|||
}
|
||||
};);
|
||||
|
||||
if (mi->using_gtid != Master_info::USE_GTID_NO &&
|
||||
mi->domain_id_filter.is_group_filtered() &&
|
||||
mi->events_queued_since_last_gtid > 0 &&
|
||||
((mi->last_queued_gtid_standalone &&
|
||||
!Log_event::is_part_of_group((Log_event_type)(uchar)
|
||||
buf[EVENT_TYPE_OFFSET])) ||
|
||||
(!mi->last_queued_gtid_standalone &&
|
||||
((uchar)buf[EVENT_TYPE_OFFSET] == XID_EVENT ||
|
||||
((uchar)buf[EVENT_TYPE_OFFSET] == QUERY_EVENT &&
|
||||
Query_log_event::peek_is_commit_rollback(buf, event_len,
|
||||
checksum_alg))))))
|
||||
{
|
||||
/* Reset the domain_id_filter flag. */
|
||||
mi->domain_id_filter.reset_filter();
|
||||
}
|
||||
|
||||
if (mi->using_gtid != Master_info::USE_GTID_NO && mi->gtid_event_seen)
|
||||
{
|
||||
if (unlikely(mi->gtid_reconnect_event_skip_count))
|
||||
|
@ -6076,6 +6060,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
|
|||
*/
|
||||
mi->gtid_current_pos.update(&mi->last_queued_gtid);
|
||||
mi->events_queued_since_last_gtid= 0;
|
||||
|
||||
/* Reset the domain_id_filter flag. */
|
||||
mi->domain_id_filter.reset_filter();
|
||||
}
|
||||
|
||||
skip_relay_logging:
|
||||
|
|
Loading…
Reference in a new issue