diff options
Diffstat (limited to 'mysql-test/suite/binlog/t')
6 files changed, 420 insertions, 2 deletions
diff --git a/mysql-test/suite/binlog/t/binlog_innodb.test b/mysql-test/suite/binlog/t/binlog_innodb.test index 153dcdd155a..5f372e6d5fd 100644 --- a/mysql-test/suite/binlog/t/binlog_innodb.test +++ b/mysql-test/suite/binlog/t/binlog_innodb.test @@ -180,7 +180,7 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; SET @old_flush = @@GLOBAL.innodb_flush_log_at_trx_commit; SET GLOBAL innodb_flush_log_at_trx_commit=1; ---let $syncs1 = query_get_value(SHOW STATUS LIKE 'Innodb_os_log_fsyncs', Value, 1) +--let $syncs1 = query_get_value(SHOW STATUS LIKE 'Innodb_data_fsyncs', Value, 1) --let $ROWS = 100 --disable_query_log let $count = $ROWS; @@ -188,7 +188,7 @@ while ($count) { eval INSERT INTO t1 VALUES ($count); dec $count; } ---let $syncs2 = query_get_value(SHOW STATUS LIKE 'Innodb_os_log_fsyncs', Value, 1) +--let $syncs2 = query_get_value(SHOW STATUS LIKE 'Innodb_data_fsyncs', Value, 1) eval SET @num_sync = $syncs2 - $syncs1; --enable_query_log diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_glle_ordered.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_glle_ordered.test new file mode 100644 index 00000000000..9c79925b4bd --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_glle_ordered.test @@ -0,0 +1,43 @@ +# +# Purpose: +# This test validates that GTIDs are ordered when mysqlbinlog outputs +# Gtid_list events. +# +# Methodology: +# Write multiple events to the binlog with different domain ids and server +# ids, and ensure that the Gtid_list event GTIDs are ordered first by domain id +# (ascending), and then sequence number (ascending). +# +# References: +# MDEV-4989: Support for GTID in mysqlbinlog +# +--source include/have_log_bin.inc + +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.server_id= 1; +INSERT INTO t2 VALUES (1); +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; +FLUSH LOGS; + +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2) +--let $MYSQLD_DATADIR=`select @@datadir` +--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/tmp_binlog.out + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/binlog_file > SEARCH_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file > $SEARCH_FILE + +--let SEARCH_PATTERN= Gtid list \[0-1-1,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1\] +--source include/search_pattern_in_file.inc + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_strict_mode.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_strict_mode.test new file mode 100644 index 00000000000..166826408d9 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_strict_mode.test @@ -0,0 +1,105 @@ +# +# Purpose: +# +# This test ensures that the mariadb-binlog CLI tool properly displays errors +# and warnings for out of order GTIDs. +# +# +# Methodology: +# +# We simulate invalid sequence numberings by manually changing gtid_seq_no to +# differ from its expected linear sequence. Specifically, we test the following +# cases: +# Test Case 1) Sequential sequence numbers results in no warnings +# Test Case 2) A skipped sequence number results in no warnings if all numbers +# are monotonic (i.e. gaps in sequence number are allowed +# provided they never decrease) +# Test Case 3) A sequence number lower than the last processed value results +# in a warning +# Test Case 4) Skipping a GTID and later receiving it results in a warning +# Test Case 5) Repeat sequence numbers result in a warning +# Test Case 6) Warnings from different domains are all displayed +# Test Case 7) A decreasing seq_no before a start-position is ignored +# Test Case 8) A decreasing seq_no inside of a --start/--stop position window +# is displayed +# Test Case 9) Error if --stop-position is not greater than or equal to +# --start-position +# Test Case 10) Strict mode warnings should be independent of --offset option +# specification +# Test Case 11) Strict mode warnings should be independent of +# --start-timestamp option specification +# Test Case 12) Specifying multiple binary logs with a log-position start +# should skip GTID state verification +# Test Case 13) If multiple binary logs should be specified but a middle log +# is missing, we should detect that and warn when using -vvv +# Test Case 14) If a --stop-position GTID occurs before the first specified +# binlog's GLLE, error +# +# Note that test cases are tested under three scenarios: +# 1) --gtid-strict-mode should error and immediately quit with error on out of +# order GTIDs +# 2) --skip-gtid-strict-mode -vvv should not quit early or with error when +# encountering out of order GTIDs; however should produce warnings after +# binlog processing +# 3) --skip-gtid-strict-mode should neither produce errors nor warnings when +# encountering out of order GTIDs +# +# References: +# MDEV-4989: Support for GTID in mysqlbinlog +# + +--source include/have_log_bin.inc + +--echo ############################### +--echo # Test Setup +--echo ############################### + +## Save old state +# +let orig_gtid_domain_id = `select @@session.gtid_domain_id`; +let orig_server_id = `select @@session.server_id`; +RESET MASTER; + +--echo #################################################### +--echo # Test Case Group 1 +--echo # +--echo # Tests with --gtid-strict-mode should error and +--echo # immediately quit with error on out of order GTIDs +--echo #################################################### +--let is_strict_mode= 1 +--let is_verbose= 0 +--let DEFAULT_ERROR_PREFIX=ERROR +--source include/mysqlbinlog_gtid_strict_mode.inc + +--echo #################################################### +--echo # Test Case Group 2 +--echo # +--echo # Test cases with --skip-gtid-strict-mode -vvv +--echo # should not quit early or with error when +--echo # encountering out of order GTIDs; however should +--echo # produce warnings after binlog processing +--echo #################################################### +--let is_strict_mode= 0 +--let is_verbose= 1 +--let DEFAULT_ERROR_PREFIX=WARNING +--source include/mysqlbinlog_gtid_strict_mode.inc + +--echo #################################################### +--echo # Test Case Group 3 +--echo # +--echo # Run test cases with --skip-gtid-strict-mode should +--echo # neither produce errors nor warnings when +--echo # encountering out of order GTIDs +--echo #################################################### +--let is_strict_mode= 0 +--let is_verbose= 0 +--let DEFAULT_ERROR_PREFIX=(ERROR|WARNING) +--source include/mysqlbinlog_gtid_strict_mode.inc + +--echo ############################## +--echo # Cleanup +--echo ############################## +--eval SET @@global.gtid_domain_id= $orig_gtid_domain_id +--eval SET @@global.server_id= $orig_server_id + +--echo End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_window.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_window.test new file mode 100644 index 00000000000..3efb8d025b9 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_window.test @@ -0,0 +1,151 @@ +# +# Purpose: +# +# This test ensures that the mariadb-binlog CLI tool can filter log events +# using GTID ranges. More specifically, this test ensures the following +# capabilities: +# 1) GTIDs can be used to filter results on local binlog files +# 2) GTIDs can be used to filter results from remote servers +# 3) For a given GTID range, its start-position is exclusive and its +# stop-position is inclusive. This allows users to receive events strictly +# after what they already have. +# 4) After the events have been written, the session server id and domain id +# are reset to their former values +# +# +# Methodology: +# +# This test validates the expected capabilities using the following test cases +# on both a local binlog file and remote server for all binlog formats. +# Test Case 1) The end of the binlog file resets the server and domain id of +# the session +# Test Case 2) Single GTID range specified +# Test Case 3) Single GTID range with different server_ids +# Test Case 4) Multiple GTID ranges specified +# Test Case 5) Multiple GTID ranges specified where the domain ids are +# listed in different orders between start/stop position +# Test Case 6) Only start position specified +# Test Case 7) Only stop position specified +# Test Case 8) Seq_no=0 in --start-position includes all events for a domain +# Test Case 9) Seq_no=0 in --stop-position excludes all events for a domain +# Test Case 10) Output stops for all domain ids when all --stop-position GTID +# values have been hit. +# Test Case 11) All GTID events from other domains are printed until +# the --stop-position values are hit +# Test Case 12) Scalar and GTID values can be used together for stop or start +# position +# Test Case 13) If the start position is delayed within the binlog, events +# occurring before that position are ignored +# Test Case 14) If start position is repeated, the last specification +# overrides all previous ones +# Test Case 15) If stop position is repeated, the last specification +# overrides all previous ones +# Test Case 16) Start position with --offset=<n> skips n events after the +# first GTID is found +# Test Case 17) Start position with --start-datetime=<T> where T occurs +# after the specified GTID results in no events before T +# Test Case 18) If --stop-position is specified, domains which are not present +# in its list should be excluded from output +# Test Case 19) If the start and stop GTIDs in any domain are equal, the +# domain should not have any output +# Test Case 20) If --start-position and --stop-position have different domain +# ids, only events from GTIDs in the --stop-position list are +# output +# Test Case 21) Successive binary logs (e.g. logs with previous logs that +# have been purged) will write events when the --start-position +# matches their Gtid_list_log_event state +# Test Case 22) Successive binary logs can be called with --stop-position and +# without --start-position +# +# To validate for data consistency, each test case compares a checksum of +# correct data against a variant created after replaying the binlog using +# --(start|stop)-position. If the checksums are identical, the test passes. +# If the checksums differ, data has been changed and the test fails. +# +# Additionally, this test validates the following error scenarios: +# Error Case 1) A GTID --start-position that does not mention all domains +# that make up the binary log state should error +# Error Case 2) A GTID --start-position with any sequence numbers which +# occur before the binary log state should result in error +# Error Case 3) A GTID --start-position with any sequence numbers that are not +# eventually processed results in error +# Error Case 4) User provides invalid positions +# Error Case 5) User provides GTID ranges with repeated domain ids +# +# References: +# MDEV-4989: Support for GTID in mysqlbinlog +# + +--source include/have_log_bin.inc + +--echo ############################### +--echo # Test Setup +--echo ############################### + +## Save old state +# +let orig_gtid_domain_id = `select @@session.gtid_domain_id`; +let orig_server_id = `select @@session.server_id`; +RESET MASTER; + + +--echo ###################################### +--echo # Test Group 1 +--echo # Run test cases on local log file +--echo ###################################### +--let is_remote= 0 +--source include/mysqlbinlog_gtid_window_test_cases.inc + +--echo ###################################### +--echo # Test Group 2 +--echo # Run test cases on remote host +--echo ###################################### +--let is_remote= 1 +--source include/mysqlbinlog_gtid_window_test_cases.inc + +# Note that error cases 1-3 are in mysqlbinlog_gtid_window_test_cases.inc +# because we validate for error consistency of GTID state between +# mariadb-binlog working on local files and receiving errors from a server + +--let err_out_= $MYSQLTEST_VARDIR/tmp/err.out +--let tmp_out_= $MYSQLTEST_VARDIR/tmp/std.out + +--let $MYSQLD_DATADIR=`select @@datadir` +--echo # +--echo # Error Case 4: +--echo # User provides invalid positions +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=z +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=z + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1- +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1- + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=-1 +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=-1 + +--echo # +--echo # Error Case 5: +--echo # User provides GTID ranges with repeated domain ids +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 + + +--echo ############################## +--echo # Cleanup +--echo ############################## +--eval SET @@global.gtid_domain_id= $orig_gtid_domain_id +--eval SET @@global.server_id= $orig_server_id + +--echo # End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_start_alter_verbose.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_start_alter_verbose.test new file mode 100644 index 00000000000..338326d144f --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_start_alter_verbose.test @@ -0,0 +1,58 @@ +# +# Purpose: +# +# This test ensures that mysqlbinlog prints a comment when two-phase alter +# is enabled which shows the original alter query issued. +# +# +# References: +# MENT-662: Finalize MDEV-11675 "Lag Free Alter On Slave" +# + +# Just row format for faster testing +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc + +#--- +# Setup +#--- +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +RESET MASTER; +create table myt (a int) engine=InnoDB; + + +#--- +# Issue ALTER +#--- +alter table myt add column (b int); + + +#--- +# Check binlog output +#--- +FLUSH LOGS; + +--disable_query_log +--let $MYSQLD_DATADIR= `select @@datadir` +--let $BINLOG_FILENAME= query_get_value(SHOW BINARY LOGS, Log_name, 1) + +--echo # Exec MYSQL_BINLOG --base64-output=decode-rows -v MYSQLD_DATADIR/BINLOG_FILENAME > MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql +--exec $MYSQL_BINLOG --base64-output=decode-rows -v $MYSQLD_DATADIR/$BINLOG_FILENAME > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql + +create table raw_binlog_rows (txt varchar(1000)); +--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n' +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql +--enable_query_log +--echo Verbose statements from : $BINLOG_FILENAME +# Output --verbose lines, with extra Windows CR's trimmed +select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%'; + +#--- +# Cleanup +#--- +drop table raw_binlog_rows; +drop table myt; +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase diff --git a/mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test b/mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test new file mode 100644 index 00000000000..d59456d72f6 --- /dev/null +++ b/mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test @@ -0,0 +1,61 @@ +# +# MENT-662: Lag Free Alter On Slave +# + +--echo # +--echo # Test verifies replay of binary logs which contain +--echo # SA/RA/CA works fine. +--echo # Generate a binary log with alter events and use mysqlbinlog tool to +--echo # generate a sql file for replay. Source it on an clean master and +--echo # verify the correctness. Use the latest binlog and repeat the same +--echo # process mentioned above and observe replay works fine. +--echo # +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_binlog_format_statement.inc + +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +create table t1 (f1 int primary key) engine=InnoDB; +create table t2 (f1 int primary key, constraint c1 foreign key (f1) references t1(f1)) engine=innodb; + +--error ER_CANT_CREATE_TABLE +alter table t2 add constraint c1 foreign key (f1) references t1(f1); + +drop table t2, t1; +select @@gtid_binlog_state; +FLUSH LOGS; + +let MYSQLD_DATADIR= `select @@datadir;`; +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_1.sql + +--echo # reset the binlog +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_1.sql" +SELECT @@gtid_binlog_state; +FLUSH LOGS; +--echo # Replay 1: One more time to simulate S->S case +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_2.sql + +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_2.sql" +SELECT @@gtid_binlog_state; +FLUSH LOGS; +--echo # Replay 2: One more time to simulate S->S case +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_3.sql +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_3.sql" +SELECT @@gtid_binlog_state; + +--echo # clean up +remove_file $MYSQLTEST_VARDIR/tmp/slave_1.sql; +remove_file $MYSQLTEST_VARDIR/tmp/slave_2.sql; +remove_file $MYSQLTEST_VARDIR/tmp/slave_3.sql; +RESET MASTER; + +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase |