Re: [Maria-developers] [Commits] 096fd8f: MDEV-9033 : Incorrect statements binlogged on slave with do_domain_ids=(...)
Hi Kristian, Can you please review this patch? - Nirbhay On Fri, Nov 13, 2015 at 5:23 PM, Nirbhay Choubey <nirbhay@mariadb.com> wrote:
revision-id: 096fd8f57664d0b3061f0e781a31bfa3cc6bf6cd parent(s): a574407444fc3ea93ca88afa93dc18154251bf74 committer: Nirbhay Choubey branch nick: 10.1.b9033 timestamp: 2015-11-13 17:23:49 -0500 message:
MDEV-9033 : 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.
--- mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result | 73 ++++++++++++++++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf | 20 ++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test | 92 +++++++++++++++++++++++++ sql/slave.cc | 19 +---- 4 files changed, 188 insertions(+), 16 deletions(-)
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result b/mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result new file mode 100644 index 0000000..fdee91f --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result @@ -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. diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf new file mode 100644 index 0000000..80b6649 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf @@ -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 diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test new file mode 100644 index 0000000..8b51d96 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test @@ -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. diff --git a/sql/slave.cc b/sql/slave.cc index fed171b..b93fb3d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5870,22 +5870,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)) @@ -6071,6 +6055,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: _______________________________________________ commits mailing list commits@mariadb.org https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits
Nirbhay Choubey <nirbhay@mariadb.com> writes:
Can you please review this patch?
- Nirbhay
It looks ok. - Kristian.
On Fri, Nov 13, 2015 at 5:23 PM, Nirbhay Choubey <nirbhay@mariadb.com> wrote:
revision-id: 096fd8f57664d0b3061f0e781a31bfa3cc6bf6cd parent(s): a574407444fc3ea93ca88afa93dc18154251bf74 committer: Nirbhay Choubey branch nick: 10.1.b9033 timestamp: 2015-11-13 17:23:49 -0500 message:
MDEV-9033 : 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.
--- mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result | 73 ++++++++++++++++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf | 20 ++++++ mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test | 92 +++++++++++++++++++++++++ sql/slave.cc | 19 +---- 4 files changed, 188 insertions(+), 16 deletions(-)
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result b/mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result new file mode 100644 index 0000000..fdee91f --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_mdev9033.result @@ -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. diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf new file mode 100644 index 0000000..80b6649 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.cnf @@ -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 diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test new file mode 100644 index 0000000..8b51d96 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev9033.test @@ -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. diff --git a/sql/slave.cc b/sql/slave.cc index fed171b..b93fb3d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5870,22 +5870,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)) @@ -6071,6 +6055,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: _______________________________________________ commits mailing list commits@mariadb.org https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits
Mailing list: https://launchpad.net/~maria-developers Post to : maria-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~maria-developers More help : https://help.launchpad.net/ListHelp
participants (2)
-
Kristian Nielsen
-
Nirbhay Choubey