mirror of
https://github.com/MariaDB/server.git
synced 2025-05-04 06:05:05 +03:00
Adding an event that can be used to denote that an incident occured on the master. The event can be used to denote a gap in the replication stream, but can also be used to denote other incidents. In addition, the injector interface is extended with functions to generate an incident event. The function will also rotate the binary log after generating an incident event to get a fresh binary log. client/Makefile.am: Adding file rpl_constants.h with constants for replication. mysql-test/extra/binlog_tests/binlog.test: Binlog position change mysql-test/extra/binlog_tests/binlog_insert_delayed.test: Binlog position change mysql-test/extra/binlog_tests/ctype_cp932_binlog.test: Binlog position change mysql-test/extra/binlog_tests/ctype_ucs_binlog.test: Binlog position change mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Binlog position change mysql-test/extra/rpl_tests/rpl_deadlock.test: Binlog position change mysql-test/extra/rpl_tests/rpl_log.test: Binlog position change mysql-test/extra/rpl_tests/rpl_multi_query.test: Binlog position change mysql-test/extra/rpl_tests/rpl_row_charset.test: Binlog position change mysql-test/extra/rpl_tests/rpl_row_sp002.test: Binlog position change mysql-test/extra/rpl_tests/rpl_row_sp003.test: Binlog position change mysql-test/extra/rpl_tests/rpl_stm_charset.test: Binlog position change mysql-test/include/show_binlog_events.inc: Binlog position change mysql-test/r/binlog_row_binlog.result: Result change mysql-test/r/binlog_row_ctype_ucs.result: Result change mysql-test/r/binlog_row_insert_select.result: Result change mysql-test/r/binlog_row_mix_innodb_myisam.result: Result change mysql-test/r/binlog_stm_binlog.result: Result change mysql-test/r/binlog_stm_ctype_ucs.result: Result change mysql-test/r/binlog_stm_insert_select.result: Result change mysql-test/r/binlog_stm_mix_innodb_myisam.result: Result change mysql-test/r/ctype_cp932_binlog_row.result: Result change mysql-test/r/ctype_cp932_binlog_stm.result: Result change mysql-test/r/flush_block_commit_notembedded.result: Result change mysql-test/r/rpl_000015.result: Result change mysql-test/r/rpl_change_master.result: Result change mysql-test/r/rpl_deadlock_innodb.result: Result change mysql-test/r/rpl_flushlog_loop.result: Result change mysql-test/r/rpl_loaddata.result: Result change mysql-test/r/rpl_loaddata_s.result: Result change mysql-test/r/rpl_log_pos.result: Result change mysql-test/r/rpl_ndb_charset.result: Result change mysql-test/r/rpl_ndb_log.result: Result change mysql-test/r/rpl_ndb_multi.result: Result change mysql-test/r/rpl_rbr_to_sbr.result: Result change mysql-test/r/rpl_rotate_logs.result: Result change mysql-test/r/rpl_row_basic_11bugs.result: Result change mysql-test/r/rpl_row_charset.result: Result change mysql-test/r/rpl_row_create_table.result: Result change mysql-test/r/rpl_row_delayed_ins.result: Result change mysql-test/r/rpl_row_drop.result: Result change mysql-test/r/rpl_row_flsh_tbls.result: Result change mysql-test/r/rpl_row_inexist_tbl.result: Result change mysql-test/r/rpl_row_log.result: Result change mysql-test/r/rpl_row_log_innodb.result: Result change mysql-test/r/rpl_row_max_relay_size.result: Result change mysql-test/r/rpl_row_reset_slave.result: Result change mysql-test/r/rpl_row_until.result: Result change mysql-test/r/rpl_server_id1.result: Result change mysql-test/r/rpl_server_id2.result: Result change mysql-test/r/rpl_sp.result: Result change mysql-test/r/rpl_stm_charset.result: Result change mysql-test/r/rpl_stm_flsh_tbls.result: Result change mysql-test/r/rpl_stm_log.result: Result change mysql-test/r/rpl_stm_max_relay_size.result: Result change mysql-test/r/rpl_stm_multi_query.result: Result change mysql-test/r/rpl_stm_reset_slave.result: Result change mysql-test/r/rpl_stm_until.result: Result change mysql-test/r/rpl_switch_stm_row_mixed.result: Result change mysql-test/r/rpl_truncate_2myisam.result: Result change mysql-test/r/rpl_truncate_3innodb.result: Result change mysql-test/r/rpl_truncate_7ndb.result: Result change mysql-test/r/user_var-binlog.result: Result change mysql-test/t/binlog_row_mix_innodb_myisam.test: Binlog position change mysql-test/t/binlog_stm_mix_innodb_myisam.test: Binlog position change mysql-test/t/ctype_cp932_binlog_stm.test: Binlog position change mysql-test/t/mysqlbinlog.test: Binlog position change mysql-test/t/mysqlbinlog2.test: Binlog position change mysql-test/t/rpl_loaddata_s.test: Binlog position change mysql-test/t/rpl_log_pos.test: Binlog position change mysql-test/t/rpl_row_basic_11bugs.test: Binlog position change mysql-test/t/rpl_row_create_table.test: Binlog position change mysql-test/t/rpl_row_flsh_tbls.test: Binlog position change mysql-test/t/rpl_row_mysqlbinlog.test: Binlog position change mysql-test/t/rpl_sp.test: Binlog position change mysql-test/t/rpl_stm_flsh_tbls.test: Binlog position change mysql-test/t/rpl_switch_stm_row_mixed.test: Binlog position change mysql-test/t/user_var-binlog.test: Binlog position change sql/Makefile.am: Adding file rpl_constants.h with constants for replication. sql/log_event.cc: Changing prototype for read_str() to be const-correct and changing code to match that. Adding incident log event. sql/log_event.h: Adding incident log event. sql/rpl_injector.cc: Adding support for generating incidents into the binary log. sql/rpl_injector.h: Adding support for generating incidents into the binary log. sql/share/errmsg.txt: Adding new error message to indicate an incident. sql/sql_parse.cc: Adding code to generate an incident log event just before executing a REPLACE if the variable "incident_database_resync_on_replace" is set. mysql-test/r/rpl_incident.result: New BitKeeper file ``mysql-test/r/rpl_incident.result'' mysql-test/t/rpl_incident.test: New BitKeeper file ``mysql-test/t/rpl_incident.test'' sql/rpl_constants.h: New BitKeeper file ``sql/rpl_constants.h''
320 lines
9.5 KiB
Plaintext
320 lines
9.5 KiB
Plaintext
##################################################################
|
||
# 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 #
|
||
##################################################################
|
||
# Include Section
|
||
# Make sure that we have row based bin log
|
||
-- source include/have_binlog_format_row.inc
|
||
# Embedded server doesn't support binlogging
|
||
-- source include/not_embedded.inc
|
||
-- source include/master-slave.inc
|
||
|
||
# Setup Section
|
||
# we need this for getting fixed timestamps inside of this test
|
||
|
||
--disable_query_log
|
||
select "---Setup Section --" as "";
|
||
--enable_query_log
|
||
|
||
set timestamp=1000000000;
|
||
|
||
--disable_warnings
|
||
DROP TABLE IF EXISTS t1,t2,t3;
|
||
--enable_warnings
|
||
|
||
connection master;
|
||
CREATE TABLE t1(word VARCHAR(20));
|
||
CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
|
||
CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
|
||
|
||
|
||
# Test Section
|
||
# Lets start by putting some data into the tables.
|
||
|
||
--disable_query_log
|
||
INSERT INTO t1 VALUES ("abirvalg");
|
||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
|
||
LOAD DATA INFILE '../std_data_ln/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);
|
||
|
||
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
|
||
|
||
|
||
--disable_query_log
|
||
select "---Test1 check table load --" as "";
|
||
--enable_query_log
|
||
|
||
# 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
|
||
--disable_query_log
|
||
select "--- Test 1 Dump binlog to file --" as "";
|
||
--enable_query_log
|
||
|
||
#
|
||
# Prepare local temporary file to recreate what we have currently.
|
||
|
||
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql
|
||
|
||
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/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.
|
||
--disable_query_log
|
||
select "--- Test 1 delete tables, clean master and slave --" as "";
|
||
--enable_query_log
|
||
|
||
DROP TABLE t1;
|
||
DROP TABLE t2;
|
||
DROP TABLE t3;
|
||
|
||
sync_slave_with_master;
|
||
#we expect STOP SLAVE to produce a warning as the slave is stopped
|
||
#(the server was started with skip-slave-start)
|
||
--disable_warnings
|
||
stop slave;
|
||
--enable_warnings
|
||
--require r/slave-stopped.result
|
||
show status like 'Slave_running';
|
||
connection master;
|
||
reset master;
|
||
connection slave;
|
||
reset slave;
|
||
start slave;
|
||
--require r/slave-running.result
|
||
show status like 'Slave_running';
|
||
connection master;
|
||
|
||
# We should be clean at this point, now we will run in the file from above.
|
||
--disable_query_log
|
||
select "--- Test 1 Load from Dump binlog file --" as "";
|
||
--enable_query_log
|
||
|
||
--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/master.sql"
|
||
|
||
--disable_query_log
|
||
select "--- Test 1 Check Load Results --" as "";
|
||
--enable_query_log
|
||
|
||
# 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.
|
||
|
||
--exec rm $MYSQLTEST_VARDIR/tmp/master.sql
|
||
|
||
|
||
# this test for position option
|
||
# By setting this position to 413, we should only get the create of t3
|
||
--disable_query_log
|
||
select "--- Test 2 position test --" as "";
|
||
--enable_query_log
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=413 $MYSQLTEST_VARDIR/log/master-bin.000001
|
||
|
||
# These are tests for remote binlog.
|
||
# They should return the same as previous test.
|
||
|
||
--disable_query_log
|
||
select "--- Test 3 First Remote test --" as "";
|
||
--enable_query_log
|
||
|
||
# This is broken now
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
|
||
|
||
# This part is disabled due to bug #17654
|
||
################### Start Bug 17654 ######################
|
||
#--disable_query_log
|
||
#select "--- Test 4 Second Remote test --" as "";
|
||
#--enable_query_log
|
||
#--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
|
||
|
||
# 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;
|
||
|
||
#we expect STOP SLAVE to produce a warning as the slave is stopped
|
||
#(the server was started with skip-slave-start)
|
||
|
||
#--disable_warnings
|
||
#stop slave;
|
||
#--enable_warnings
|
||
#--require r/slave-stopped.result
|
||
#show status like 'Slave_running';
|
||
#connection master;
|
||
#reset master;
|
||
#connection slave;
|
||
#reset slave;
|
||
#start slave;
|
||
#--require r/slave-running.result
|
||
#show status like 'Slave_running';
|
||
#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.
|
||
|
||
#--exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
|
||
################### End Bug 17654 ######################
|
||
|
||
# LOAD DATA
|
||
--disable_query_log
|
||
select "--- Test 5 LOAD DATA --" as "";
|
||
--enable_query_log
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --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)
|
||
|
||
--disable_query_log
|
||
select "--- Test 6 reading stdin --" as "";
|
||
--enable_query_log
|
||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||
--exec $MYSQL_BINLOG --short-form - < $MYSQLTEST_VARDIR/log/master-bin.000001
|
||
|
||
--disable_query_log
|
||
select "--- Test 7 reading stdin w/position --" as "";
|
||
--enable_query_log
|
||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||
--exec $MYSQL_BINLOG --short-form --position=413 - < $MYSQLTEST_VARDIR/log/master-bin.000001
|
||
|
||
# Bug#16217 (mysql client did not know how not switch its internal charset)
|
||
--disable_query_log
|
||
select "--- Test 8 switch internal charset --" as "";
|
||
--enable_query_log
|
||
sync_slave_with_master;
|
||
|
||
#we expect STOP SLAVE to produce a warning as the slave is stopped
|
||
#(the server was started with skip-slave-start)
|
||
|
||
--disable_warnings
|
||
stop slave;
|
||
--enable_warnings
|
||
--require r/slave-stopped.result
|
||
show status like 'Slave_running';
|
||
connection master;
|
||
reset master;
|
||
connection slave;
|
||
reset slave;
|
||
start slave;
|
||
--require r/slave-running.result
|
||
show status like 'Slave_running';
|
||
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 $MYSQLTEST_VARDIR/log/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;
|
||
|
||
--disable_query_log
|
||
select "--- Test cleanup --" as "";
|
||
--enable_query_log
|
||
# clean up
|
||
connection master;
|
||
DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
|
||
sync_slave_with_master;
|
||
|
||
# End of 4.1 tests
|