mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
47637a3dd1
Problem: ======= Whel rpl.rpl_row_mysqlbinlog test is executed as shown below it fails with result content mismatch. perl mtr rpl_row_mysqlbinlog --mysqld=--binlog-annotate-row-events=1 Analysis: ========= When row annotations are enabled the actual query is written into the binlog which helps users to understand the query, even when row based replication is enabled. For example: Simple insert in row based replication looks like shown below. #190402 16:31:27 server id 1 end_log_pos 526 Annotate_rows: #Q> insert into t values (10) #190402 16:31:27 server id 1 end_log_pos 566 Table_map: `test`.`t` mapped to number 19 # at 566 #190402 16:31:27 server id 1 end_log_pos 600 Write_rows: table id 19 flags: STMT_END_F BINLOG ' B0GjXBMBAAAAKAAAADYCAAAAABMAAAAAAAEABHRlc3QAAXQAAQMAAQ== B0GjXBcBAAAAIgAAAFgCAAAAABMAAAAAAAEAAf/+CgAAAA== '/*!*/; # at 600 The test creates some binary log events and redirects them into a SQL file. Executes RESET MASTER and sources the SQL file back on clean master and verifies that the data is available. Please refer following steps. ../client/mysqlbinlog ./var/mysqld.1/data/master-bin.000001 > test.sql ../client/mysql -uroot -S./var/tmp/mysqld.1.sock -Dtest < test.sql ../client/mysqlbinlog ./var/mysqld.1/data/master-bin.000001 -v > row.sql When the row based replication specific SQL file is sourced once again on master the newly generated binlog will treat the entire "BASE 64" encoded event as query and write it into the binary log. Output from 'row.sql': #Q> BINLOG ' #Q> B0GjXBMBAAAAKAAAADYCAAAAABMAAAAAAAEABHRlc3QAAXQAAQMAAQ== #Q> B0GjXBcBAAAAIgAAAFgCAAAAABMAAAAAAAEAAf/+CgAAAA== #190402 16:31:27 server id 1 end_log_pos 657 Table_map: `test`.`t` mapped to number 23 # at 657 #190402 16:31:27 server id 1 end_log_pos 691 Write_rows: table id 23 flags: STMT_END_F BINLOG ' B0GjXBMBAAAAKAAAAJECAAAAABcAAAAAAAEABHRlc3QAAXQAAQMAAQ== B0GjXBcBAAAAIgAAALMCAAAAABcAAAAAAAEAAQH+CgAAAA== ### INSERT INTO `test`.`t` ### SET ### @1=10 '/*!*/; # at 691 This is expected behaviour as we cannot extract query from BASE 64 encoded input. This causes more number of binary logs to be generated when the test is executed with row annotations. The following lines from test assumes that only two binary logs will contain entire data. --echo --- Test 4 Second Remote test -- ---exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql ---exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/remote.sql In a case when row annotations are enabled the data gets spread across four binary logs. As test uses only the first two binary log files, data available in other binary logs gets missed. Hence test fails with result content mismatch as less data is avaialble. Fix: ==== Use "-to-the-last" option of "mysqlbinlog" tool which will ensure that all the available binary log specific contents are included in .sql file.
285 lines
9.2 KiB
Text
285 lines
9.2 KiB
Text
##################################################################
|
||
# Author: JBM #
|
||
# Date: 2006-02-22 #
|
||
# Purpose: To test changes to mysqlbinlog for row based bin logs #
|
||
# We are using .opt file since we need small binlog size #
|
||
##################################################################
|
||
-- source include/have_binlog_format_row.inc
|
||
-- source include/not_embedded.inc
|
||
-- source include/have_cp932.inc
|
||
-- source include/master-slave.inc
|
||
|
||
--echo ---Setup Section --
|
||
|
||
# we need this for getting fixed timestamps inside of this test
|
||
set timestamp=1000000000;
|
||
|
||
CREATE TABLE t1(word VARCHAR(20));
|
||
CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
|
||
--let position= query_get_value(SHOW MASTER STATUS, Position, 1)
|
||
CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
|
||
--let stop_position=query_get_value(SHOW MASTER STATUS, Position, 1)
|
||
--let stop_position1=`select $stop_position - 1`
|
||
--let binlog_start_pos=query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
|
||
|
||
# Test Section
|
||
# Lets start by putting some data into the tables.
|
||
|
||
INSERT INTO t1 VALUES ("abirvalg");
|
||
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
|
||
|
||
# d1 length 3000
|
||
set @d1 = 'dd1';
|
||
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
|
||
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
|
||
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
|
||
|
||
--disable_query_log
|
||
let count=500;
|
||
while ($count)
|
||
{
|
||
INSERT INTO t2 VALUES (NULL);
|
||
eval INSERT INTO t3 VALUES ($count,@d1,'20060222000000','Tested in Texas',$count*2.2);
|
||
dec $count;
|
||
}
|
||
--enable_query_log
|
||
|
||
--echo ---Test 1 check table load --
|
||
|
||
# Lets Check the tables on the Master
|
||
SELECT COUNT(*) from t1;
|
||
SELECT COUNT(*) from t2;
|
||
SELECT COUNT(*) from t3;
|
||
SELECT * FROM t1 ORDER BY word LIMIT 5;
|
||
SELECT * FROM t2 ORDER BY id LIMIT 5;
|
||
SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
|
||
|
||
# Should have the same on the slave;
|
||
|
||
sync_slave_with_master;
|
||
SELECT COUNT(*) from t1;
|
||
SELECT COUNT(*) from t2;
|
||
SELECT COUNT(*) from t3;
|
||
SELECT * FROM t1 ORDER BY word LIMIT 5;
|
||
SELECT * FROM t2 ORDER BY id LIMIT 5;
|
||
SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
|
||
|
||
# Okay time to get busy, back to master
|
||
|
||
connection master;
|
||
|
||
# simple query to show more in second binlog
|
||
insert into t1 values ("Alas");
|
||
flush logs;
|
||
|
||
# delimiters are for easier debugging in future
|
||
--echo --- Test 1 Dump binlog to file --
|
||
|
||
#
|
||
# Prepare local temporary file to recreate what we have currently.
|
||
let MYSQLD_DATADIR= `select @@datadir;`;
|
||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql
|
||
|
||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/master.sql
|
||
|
||
# Now that we have our file, lets get rid of the current database.
|
||
# Cleanup the master and the slave and try to recreate.
|
||
--echo --- Test 1 delete tables, clean master and slave --
|
||
|
||
DROP TABLE t1;
|
||
DROP TABLE t2;
|
||
DROP TABLE t3;
|
||
|
||
sync_slave_with_master;
|
||
stop slave;
|
||
--source include/wait_for_slave_to_stop.inc
|
||
connection master;
|
||
reset master;
|
||
connection slave;
|
||
reset slave;
|
||
start slave;
|
||
--source include/wait_for_slave_to_start.inc
|
||
connection master;
|
||
|
||
# We should be clean at this point, now we will run in the file from above.
|
||
--echo --- Test 1 Load from Dump binlog file --
|
||
|
||
--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/master.sql"
|
||
|
||
--echo --- Test 1 Check Load Results --
|
||
|
||
# Lets Check the tables on the Master
|
||
SELECT COUNT(*) from t1;
|
||
SELECT COUNT(*) from t2;
|
||
SELECT COUNT(*) from t3;
|
||
SELECT * FROM t1 ORDER BY word LIMIT 5;
|
||
SELECT * FROM t2 ORDER BY id LIMIT 5;
|
||
SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
|
||
|
||
# Should have the same on the slave;
|
||
|
||
sync_slave_with_master;
|
||
SELECT COUNT(*) from t1;
|
||
SELECT COUNT(*) from t2;
|
||
SELECT COUNT(*) from t3;
|
||
SELECT * FROM t1 ORDER BY word LIMIT 5;
|
||
SELECT * FROM t2 ORDER BY id LIMIT 5;
|
||
SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
|
||
connection master;
|
||
|
||
# We should be gold by the time, so I will get rid of our file.
|
||
|
||
remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
|
||
|
||
|
||
# this test for start-position option
|
||
# By setting this position to 416, we should only get the create of t3
|
||
--echo --- Test 2 position test --
|
||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --start-position=$position --stop-position=$stop_position $MYSQLD_DATADIR/master-bin.000001
|
||
|
||
# These are tests for remote binlog.
|
||
# They should return the same as previous test.
|
||
|
||
--echo --- Test 3 First Remote test --
|
||
|
||
# This is broken now
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$stop_position --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
|
||
|
||
--echo --- Test 4 Second Remote test --
|
||
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --to-last-log master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
|
||
|
||
# Now that we have our file, lets get rid of the current database.
|
||
# Cleanup the master and the slave and try to recreate.
|
||
|
||
DROP TABLE t1;
|
||
DROP TABLE t2;
|
||
DROP TABLE t3;
|
||
|
||
sync_slave_with_master;
|
||
|
||
stop slave;
|
||
--source include/wait_for_slave_to_stop.inc
|
||
connection master;
|
||
reset master;
|
||
connection slave;
|
||
reset slave;
|
||
start slave;
|
||
--source include/wait_for_slave_to_start.inc
|
||
connection master;
|
||
|
||
# We should be clean at this point, now we will run in the file from above.
|
||
|
||
--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/remote.sql"
|
||
|
||
# Lets Check the tables on the Master
|
||
|
||
SELECT COUNT(*) from t1;
|
||
SELECT COUNT(*) from t2;
|
||
SELECT COUNT(*) from t3;
|
||
SELECT * FROM t1 ORDER BY word LIMIT 5;
|
||
SELECT * FROM t2 ORDER BY id LIMIT 5;
|
||
SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
|
||
|
||
# Should have the same on the slave;
|
||
|
||
sync_slave_with_master;
|
||
SELECT COUNT(*) from t1;
|
||
SELECT COUNT(*) from t2;
|
||
SELECT COUNT(*) from t3;
|
||
SELECT * FROM t1 ORDER BY word LIMIT 5;
|
||
SELECT * FROM t2 ORDER BY id LIMIT 5;
|
||
SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
|
||
connection master;
|
||
|
||
# We should be gold by the time, so I will get rid of our file.
|
||
|
||
--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
|
||
################### End Bug 17654 ######################
|
||
|
||
# What is the point of this test? It seems entirely pointless. It
|
||
# might make sense for statement-based replication, but for row-based
|
||
# replication the LOAD DATA INFILE is printed just as empty
|
||
# transactions. /Matz
|
||
|
||
# LOAD DATA
|
||
--echo --- Test 5 LOAD DATA --
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$binlog_start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
|
||
|
||
# Bug#7853 (mysqlbinlog does not accept input from stdin)
|
||
|
||
--echo --- Test 6 reading stdin --
|
||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_position1 - < $MYSQLD_DATADIR/master-bin.000001
|
||
|
||
--echo --- Test 7 reading stdin w/position --
|
||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||
--exec $MYSQL_BINLOG --short-form --start-position=$position --stop-position=$stop_position - < $MYSQLD_DATADIR/master-bin.000001
|
||
|
||
# Bug#16217 (mysql client did not know how not switch its internal charset)
|
||
--echo --- Test 8 switch internal charset --
|
||
sync_slave_with_master;
|
||
|
||
stop slave;
|
||
--source include/wait_for_slave_to_stop.inc
|
||
connection master;
|
||
reset master;
|
||
connection slave;
|
||
reset slave;
|
||
start slave;
|
||
--source include/wait_for_slave_to_start.inc
|
||
connection master;
|
||
|
||
create table t4 (f text character set utf8);
|
||
create table t5 (f text character set cp932);
|
||
--exec $MYSQL --default-character-set=utf8 test -e "insert into t4 values(_utf8'ソ')"
|
||
--exec $MYSQL --default-character-set=cp932 test -e "insert into t5 values(_cp932'<27>\');"
|
||
flush logs;
|
||
rename table t4 to t04, t5 to t05;
|
||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL --default-character-set=utf8
|
||
# original and recovered data must be equal
|
||
select HEX(f) from t04;
|
||
select HEX(f) from t4;
|
||
select HEX(f) from t05;
|
||
select HEX(f) from t5;
|
||
|
||
# slave should have same
|
||
sync_slave_with_master;
|
||
select HEX(f) from t04;
|
||
select HEX(f) from t4;
|
||
select HEX(f) from t05;
|
||
select HEX(f) from t5;
|
||
|
||
--echo --- Test cleanup --
|
||
# clean up
|
||
connection master;
|
||
sync_slave_with_master;
|
||
|
||
connection master;
|
||
DROP TABLE t1, t2, t3, t04, t05, t4, t5;
|
||
|
||
# BUG#17654 also test mysqlbinlog to ensure it can read the binlog from a remote server
|
||
# and ensure that the results are the same as if read from a file (the same file).
|
||
|
||
CREATE TABLE t1 (a INT NOT NULL KEY, b INT);
|
||
INSERT INTO t1 VALUES(1,1);
|
||
SELECT * FROM t1;
|
||
FLUSH LOGS;
|
||
|
||
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
|
||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/local.sql
|
||
|
||
--diff_files $MYSQLTEST_VARDIR/tmp/local.sql $MYSQLTEST_VARDIR/tmp/remote.sql
|
||
--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
|
||
--remove_file $MYSQLTEST_VARDIR/tmp/local.sql
|
||
DROP TABLE t1;
|
||
|
||
sync_slave_with_master;
|
||
|
||
# End of 4.1 tests
|
||
--source include/rpl_end.inc
|