mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#46640: output from mysqlbinlog command in 5.1 breaks replication
The BINLOG statement was sharing too much code with the slave SQL thread, introduced with the patch for Bug#32407. This caused statements to be logged with the wrong server_id, the id stored inside the events of the BINLOG statement rather than the id of the running server. Fix by rearranging code a bit so that only relevant parts of the code are executed by the BINLOG statement, and the server_id of the server executing the statements will not be overrided by the server_id stored in the 'format description BINLOG statement'. mysql-test/extra/binlog_tests/binlog.test: Added test to verify if the server_id stored in the 'format description BINLOG statement' will override the server_id of the server executing the statements. mysql-test/suite/binlog/r/binlog_row_binlog.result: Test result for bug#46640 mysql-test/suite/binlog/r/binlog_stm_binlog.result: Test result for bug#46640 sql/log_event.cc: Moved rows_event_stmt_clean() call from update_pos() to apply_event(). This in any case makes more sense, and is needed as update_pos() is no longer called when executing BINLOG statements. Moved setting of rli->relay_log.description_event_for_exec from Format_description_log_event::do_update_pos() to Format_description_log_event::do_apply_event() sql/log_event_old.cc: Moved rows_event_stmt_clean() call from update_pos() to apply_event(). This in any case makes more sense, and is needed as update_pos() is no longer called when executing BINLOG statements. sql/slave.cc: The skip flag is no longer needed, as the code path for BINLOG statement has been cleaned up. sql/sql_binlog.cc: Don't invoke the update_pos() code path for the BINLOG statement, as it contains code that is redundant and/or harmful (especially setting thd->server_id).
This commit is contained in:
@ -270,3 +270,42 @@ INSERT INTO test.t1 VALUES (1), (2);
|
||||
CREATE TABLE test.t2 SELECT * FROM test.t1;
|
||||
USE test;
|
||||
DROP TABLES t1, t2;
|
||||
|
||||
#
|
||||
# Bug#46640
|
||||
# This test verifies if the server_id stored in the "format
|
||||
# description BINLOG statement" will override the server_id
|
||||
# of the server executing the statements.
|
||||
#
|
||||
|
||||
connect (fresh,localhost,root,,test);
|
||||
connection fresh;
|
||||
|
||||
RESET MASTER;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY);
|
||||
|
||||
# Format description event, with server_id = 10;
|
||||
BINLOG '
|
||||
3u9kSA8KAAAAZgAAAGoAAAABAAQANS4xLjM1LW1hcmlhLWJldGExLWRlYnVnLWxvZwAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAADe72RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
|
||||
';
|
||||
|
||||
# What server_id is logged for a statement? Should be our own, not the
|
||||
# one from the format description event.
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
# INSERT INTO t1 VALUES (2), with server_id=20. Check that this is logged
|
||||
# with our own server id, not the 20 from the BINLOG statement.
|
||||
BINLOG '
|
||||
3u9kSBMUAAAAKQAAAJEBAAAAABoAAAAAAAAABHRlc3QAAnQxAAEDAAA=
|
||||
3u9kSBcUAAAAIgAAALMBAAAQABoAAAAAAAEAAf/+AgAAAA==
|
||||
';
|
||||
|
||||
# Show binlog events to check that server ids are correct.
|
||||
--replace_column 1 # 2 # 5 #
|
||||
--replace_regex /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
|
||||
SHOW BINLOG EVENTS;
|
||||
|
||||
DROP TABLE t1;
|
||||
disconnect fresh;
|
||||
|
||||
|
@ -1309,3 +1309,27 @@ INSERT INTO test.t1 VALUES (1), (2);
|
||||
CREATE TABLE test.t2 SELECT * FROM test.t1;
|
||||
USE test;
|
||||
DROP TABLES t1, t2;
|
||||
RESET MASTER;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY);
|
||||
BINLOG '
|
||||
3u9kSA8KAAAAZgAAAGoAAAABAAQANS4xLjM1LW1hcmlhLWJldGExLWRlYnVnLWxvZwAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAADe72RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
|
||||
';
|
||||
INSERT INTO t1 VALUES (1);
|
||||
BINLOG '
|
||||
3u9kSBMUAAAAKQAAAJEBAAAAABoAAAAAAAAABHRlc3QAAnQxAAEDAAA=
|
||||
3u9kSBcUAAAAIgAAALMBAAAQABoAAAAAAAEAAf/+AgAAAA==
|
||||
';
|
||||
SHOW BINLOG EVENTS;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
# # Format_desc 1 # Server ver: #, Binlog ver: #
|
||||
# # Query 1 # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY)
|
||||
# # Query 1 # BEGIN
|
||||
# # Table_map 1 # table_id: # (test.t1)
|
||||
# # Write_rows 1 # table_id: # flags: STMT_END_F
|
||||
# # Query 1 # COMMIT
|
||||
# # Query 1 # BEGIN
|
||||
# # Table_map 1 # table_id: # (test.t1)
|
||||
# # Write_rows 1 # table_id: # flags: STMT_END_F
|
||||
# # Query 1 # COMMIT
|
||||
DROP TABLE t1;
|
||||
|
@ -784,3 +784,24 @@ INSERT INTO test.t1 VALUES (1), (2);
|
||||
CREATE TABLE test.t2 SELECT * FROM test.t1;
|
||||
USE test;
|
||||
DROP TABLES t1, t2;
|
||||
RESET MASTER;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY);
|
||||
BINLOG '
|
||||
3u9kSA8KAAAAZgAAAGoAAAABAAQANS4xLjM1LW1hcmlhLWJldGExLWRlYnVnLWxvZwAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAADe72RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
|
||||
';
|
||||
INSERT INTO t1 VALUES (1);
|
||||
BINLOG '
|
||||
3u9kSBMUAAAAKQAAAJEBAAAAABoAAAAAAAAABHRlc3QAAnQxAAEDAAA=
|
||||
3u9kSBcUAAAAIgAAALMBAAAQABoAAAAAAAEAAf/+AgAAAA==
|
||||
';
|
||||
SHOW BINLOG EVENTS;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
# # Format_desc 1 # Server ver: #, Binlog ver: #
|
||||
# # Query 1 # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY)
|
||||
# # Query 1 # use `test`; INSERT INTO t1 VALUES (1)
|
||||
# # Query 1 # BEGIN
|
||||
# # Table_map 1 # table_id: # (test.t1)
|
||||
# # Write_rows 1 # table_id: # flags: STMT_END_F
|
||||
# # Query 1 # COMMIT
|
||||
DROP TABLE t1;
|
||||
|
Reference in New Issue
Block a user