mirror of
https://github.com/MariaDB/server.git
synced 2025-04-28 06:45:23 +03:00
New Feature: =========== This commit extends the mariadb-binlog capabilities to allow events to be filtered by GTID ranges. More specifically, the --start-position and --stop-position arguments have been extended to accept values formatted as a list of GTID positions, e.g. --start-position=0-1-0,1-2-55. The following specific capabilities are addressed: 1) GTIDs can be used to filter results on local binlog files 2) GTIDs can be used to filter results from remote servers 3) Implemented --gtid-strict-mode that ensures the GTID event stream in each domain is monotonically increasing 4) Added new level of verbosity in mysqlbinlog -vvv to print additional diagnostic information/warnings about invalid GTID states 5) For a given GTID range, its start and stop position parameters aim to mimic the behaviors of CHANGE MASTER TO MASTER_USE_GTID=slave_pos and START SLAVE UNTIL master_gtid_pos=<GTID>, respectively. In particular, the start-position list expresses a gtid state of the server, similarly to how @@global.gtid_slave_pos expresses the gtid state of a slave server when connecting to a master with MASTER_USE_GTID=slave_pos. The GTID start-position list is exclusive and the stop-position list is inclusive. This allows users to receive events strictly after those that they already have, and is useful in cases of point in (logical) time recovery including 1) events were received out of order and should be re-sent, or 2) specifying the gtid state of a slave to get events newer than their current state. If a seq_no is 0 for start-position, it means to include the entirety of the domain. If a seq_no is 0 for stop-position, it means to exclude all events from that domain. The GTIDs provided in a start position argument must match with the GTID state of the first processed log (i.e. those listed in the Gtid_list event). If a stop position is provided, the events that are output are limited to only those with domain ids listed in the argument. When specifying combinations of start and stop positions, the following behaviors are expected: [--start-position without --stop-position]: Events that have domain ids in the start position are output if their seq_no occurs after the respective start position. Events with domain ids that are unspecified in the start position list are also output. Note that if the Gtid_list event of the first binary log is populated (i.e. non-empty), each domain in the Gtid_list must be present in the start-position list with a seq_no at or after the listed value. This behavior mimics how a slave only processes events after the state provided by @@global.gtid_slave_pos when connecting to a master with CHANGE MASTER TO MASTER_USE_GTID=slave_pos. [--stop-position without --start-position]: Output is limited to only events with both 1) domain ids that are present in the given stop position list and 2) seq_nos that are less than or equal to their respective stop GTID. Once all GTIDs in the stop position list have been processed, the program will stop processing log files. This behavior mimics how START SLAVE UNTIL master_gtid_pos=<G> has a slave only process events with domain ids present in G with their seq_nos at or before the respective gtid. [--start-position and --stop-position]: Output consists of the intersection between the events permitted by both the start and stop position rules. More concretely, the output can be defined by a union of the following rules: 1. For domains which exist in both the start and stop position lists, the events which exist in-between these positions (exclusive start, inclusive stop) are output 2. For all other events, the rules of [--stop-position without --start-position] are followed This is due to the implicit filtering within each individual rule. Even though the start position rule always includes events from unspecified domains, the stop position rule takes precedence because it always excludes events from unspecified domains. In other words, events which the start position rule would have included would then always be excluded by the stop position rule. [neither --start-position nor --stop-position]: Events are not omitted based on GTID positioning; however, --gtid-strict-mode and -vvv can still analyze gtid correctness for warning and error reporting. [repeated specification of --start-position or --stop-position]: Subsequent specifications of start and stop positions completely override previous ones. E.g., if invoked as mysqlbinlog --start-position=<G1> --start-position=<G2> ... All GTIDs specified in G1 are ignored and only those specified in G2 are used for the start position. A few additional notes: 1) this commit squashes together the commits: f4319661120e-78a9d49907ba 2) Changed rpl.rpl_blackhole_row_annotate test because it has out of order GTIDs in its binlog, so I added --skip-gtid-strict-mode 3) After all binlog events have been written, the session server id and domain id are reset to their values in the global state Reviewed By: =========== Andrei Elkin: <andrei.elkin@mariadb.com>
607 lines
20 KiB
PHP
607 lines
20 KiB
PHP
#
|
|
# This file runs test cases for providing GTIDs to --start-position and
|
|
# --stop-position arguments in mariadb-binlog
|
|
#
|
|
# param $is_remote boolean (0 for false, 1 for true) to perform a local file
|
|
# or remote host analysis
|
|
#
|
|
|
|
--let MYSQLD_DATADIR=`select @@datadir`
|
|
--let data_inconsistent_err= "table data is inconsistent after replaying binlog using GTID start/stop positions";
|
|
--let $tmp_out_ = $MYSQLTEST_VARDIR/tmp/null.log
|
|
|
|
## Initialize test data
|
|
#
|
|
set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22");
|
|
SET timestamp=@a;
|
|
RESET MASTER;
|
|
SET @@session.gtid_domain_id= 0;
|
|
SET @@session.server_id= 1;
|
|
--let $empty_binlog_pos= query_get_value(SHOW MASTER STATUS,Position, 1)
|
|
CREATE TABLE t1 (a int);
|
|
SET timestamp=@a+1;
|
|
INSERT INTO t1 values (1), (2);
|
|
--let test2_t1_mid_checksum= `CHECKSUM TABLE t1`
|
|
|
|
SET @@session.gtid_domain_id= 1;
|
|
SET @@session.server_id= 2;
|
|
SET timestamp=@a+2;
|
|
CREATE TABLE t2 (a int);
|
|
SET timestamp=@a+3;
|
|
INSERT INTO t2 values (1);
|
|
--let t2_mid_checksum= `CHECKSUM TABLE t2`
|
|
|
|
SET @@session.gtid_domain_id= 0;
|
|
SET @@session.server_id= 1;
|
|
SET timestamp=@a+4;
|
|
INSERT INTO t1 values (3), (4);
|
|
--let t1_final_checksum_pos= query_get_value(SHOW MASTER STATUS,Position, 1)
|
|
--let t1_final_checksum= `CHECKSUM TABLE t1`
|
|
|
|
SET @@session.gtid_domain_id= 1;
|
|
SET @@session.server_id= 2;
|
|
INSERT INTO t2 values (2);
|
|
--let test4_t2_good_checksum= `CHECKSUM TABLE t2`
|
|
|
|
SET @@session.server_id= 3;
|
|
INSERT INTO t2 values (3);
|
|
--let test3_t2_good_checksum= `CHECKSUM TABLE t2`
|
|
|
|
SET @@session.server_id= 2;
|
|
INSERT INTO t2 values (4);
|
|
--let t2_final_checksum= `CHECKSUM TABLE t2`
|
|
|
|
FLUSH LOGS;
|
|
|
|
# Multiple binlog file case, used by test 18
|
|
SET @@session.gtid_domain_id= 0;
|
|
SET @@session.server_id= 1;
|
|
CREATE TABLE t3 (a int);
|
|
INSERT INTO t3 VALUES (1);
|
|
--let t3_final_checksum= `CHECKSUM TABLE t3`
|
|
|
|
FLUSH LOGS;
|
|
|
|
--echo # Gtid list event of the 2nd binlog file whose content is
|
|
--echo # matched against --start-position in the following tests:
|
|
--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2)
|
|
--source include/show_gtid_list.inc
|
|
--let $binlog_file=
|
|
|
|
--let BINLOG_FILE= query_get_value(SHOW BINARY LOGS, Log_name, 1)
|
|
--let BINLOG_FILE2= query_get_value(SHOW BINARY LOGS, Log_name, 2)
|
|
|
|
if ($is_remote == 0)
|
|
{
|
|
--let BINLOG_FILE_PARAM=$MYSQLD_DATADIR/$BINLOG_FILE.orig
|
|
--let BINLOG_FILE_PARAM2=$MYSQLD_DATADIR/$BINLOG_FILE2.orig
|
|
}
|
|
if ($is_remote == 1)
|
|
{
|
|
--let BINLOG_FILE_PARAM= --read-from-remote-server $BINLOG_FILE
|
|
--let BINLOG_FILE_PARAM2= --read-from-remote-server $BINLOG_FILE2
|
|
}
|
|
|
|
--copy_file $MYSQLD_DATADIR/$BINLOG_FILE $MYSQLD_DATADIR/$BINLOG_FILE.orig
|
|
--copy_file $MYSQLD_DATADIR/$BINLOG_FILE2 $MYSQLD_DATADIR/$BINLOG_FILE2.orig
|
|
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t3;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 1:
|
|
--echo # The end of the binlog file resets the server and domain id of the
|
|
--echo # session
|
|
|
|
# As gtid_domain_id and server_id should not change after reading binlog in GTID
|
|
# mode, change variables to otherwise-unused values to ensure they remain
|
|
--let $reset_gtid_domain_id = `select @@session.gtid_domain_id`
|
|
--let $reset_server_id = `select @@session.server_id`
|
|
SET @@session.gtid_domain_id= 10;
|
|
SET @@session.server_id= 20;
|
|
|
|
# Replay the binlog
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | $MYSQL
|
|
--let $test_gtid_domain_id = `select @@session.gtid_domain_id`
|
|
|
|
# Ensure variables haven't changed
|
|
--let $assert_text = session gtid_domain_id should not change when reading binlog in GTID mode
|
|
--let $assert_cond = @@session.gtid_domain_id = 10
|
|
--source include/assert.inc
|
|
--let $assert_text = session server_id should not change when reading binlog in GTID mode
|
|
--let $assert_cond = @@session.server_id = 20
|
|
--source include/assert.inc
|
|
|
|
# Reset back to previous state
|
|
--eval SET @@session.gtid_domain_id= $reset_gtid_domain_id
|
|
--eval SET @@session.server_id= $reset_server_id
|
|
DROP TABLE t1;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 2:
|
|
--echo # Single GTID range specified
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | $MYSQL
|
|
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 3:
|
|
--echo # Single GTID range with different server_ids
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | $MYSQL
|
|
|
|
if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should exclude domain 0 from stop position";
|
|
}
|
|
DROP TABLE t2;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 4:
|
|
--echo # Multiple GTID ranges specified
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | $MYSQL
|
|
|
|
# Reuse checksum spot from test 4
|
|
if ($t1_final_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if ($test4_t2_good_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 5:
|
|
--echo # Multiple GTID ranges specified where the domain ids are listed in
|
|
--echo # different orders between start/stop position
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | $MYSQL
|
|
|
|
# Reuse checksum spot from test 4
|
|
if ($t1_final_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if ($test4_t2_good_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 6:
|
|
--echo # Only start position specified
|
|
CREATE TABLE t1 (a int);
|
|
INSERT INTO t1 values (3), (4);
|
|
--let test6_t1_mid_checksum= `CHECKSUM TABLE t1`
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (a int);
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-2 | $MYSQL
|
|
if ($test6_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if ($t2_final_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 7:
|
|
--echo # Only stop position specified
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-2 | $MYSQL
|
|
|
|
# Reuse checksum spot from test 2
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 8:
|
|
--echo # Seq_no=0 in --start-position includes all events for a domain
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | $MYSQL
|
|
if ($t1_final_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die "t1 data should be complete as binlog replay should include domain 0 entirely in results";
|
|
}
|
|
if ($t2_final_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die "t2 data should be complete as binlog replay should include domain 1 entirely in results";
|
|
}
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
--echo #
|
|
--echo # Test Case 9:
|
|
--echo # Seq_no=0 in --stop-position excludes all events for a domain
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | $MYSQL
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should exclude domain 0 from results";
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from results";
|
|
}
|
|
|
|
--echo #
|
|
--echo # Test Case 10:
|
|
--echo # Output stops for all domain ids when all --stop-position GTID values
|
|
--echo # have been hit.
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-2 | $MYSQL
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from results";
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Test Case 11:
|
|
--echo # All GTID events from other domains are printed until the
|
|
--echo # --stop-position values are hit
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=1-3-4 | $MYSQL
|
|
if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should exclude domain 0 from stop position";
|
|
}
|
|
DROP TABLE t2;
|
|
|
|
--echo #
|
|
--echo # Test Case 12:
|
|
--echo # Scalar and GTID values can be used together for stop or start
|
|
--echo # position
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=$empty_binlog_pos --stop-position=0-1-2 | $MYSQL
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=$t1_final_checksum_pos | $MYSQL
|
|
if ($t1_final_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if ($t2_mid_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
|
|
--echo #
|
|
--echo # Test Case 13:
|
|
--echo # If the start position is delayed within the binlog, events occurring
|
|
--echo # before that position are ignored
|
|
CREATE TABLE t1 (a int);
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | $MYSQL
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from results";
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Test Case 14:
|
|
--echo # If start position is repeated, the last specification overrides all
|
|
--echo # previous ones
|
|
CREATE TABLE t1 (a int);
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | $MYSQL
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from results";
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Test Case 15:
|
|
--echo # If stop position is repeated, the last specification overrides all
|
|
--echo # previous ones
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | $MYSQL
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from results";
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Test Case 16:
|
|
--echo # Start position with --offset=<n> skips n events after the first
|
|
--echo # GTID is found
|
|
|
|
# t1 needs to be specified because its creation should be skipped from
|
|
# --offset specification
|
|
CREATE TABLE t1 (a int);
|
|
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | $MYSQL
|
|
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude events after GTID 0-1-2";
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Test Case 17:
|
|
--echo # Start position with --start-datetime=<T> where T occurs after the
|
|
--echo # specified GTID results in no events before T
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | $MYSQL
|
|
if ($t2_mid_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should exclude events before the given start-datetime";
|
|
}
|
|
DROP TABLE t2;
|
|
|
|
--echo #
|
|
--echo # Test Case 18:
|
|
--echo # If --stop-position is specified, domains which are not present
|
|
--echo # in its list should be excluded from output
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=1-3-4 | $MYSQL
|
|
|
|
if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should exclude domain 0 from stop position";
|
|
}
|
|
DROP TABLE t2;
|
|
|
|
--echo #
|
|
--echo # Test Case 19:
|
|
--echo # If the start and stop GTIDs in any domain are equal, the domain
|
|
--echo # should not have any output
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | $MYSQL
|
|
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should exclude domain 0 from stop position";
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from stop position";
|
|
}
|
|
|
|
--echo #
|
|
--echo # Test Case 20:
|
|
--echo # If --start-position and --stop-position have different domain ids,
|
|
--echo # only events from GTIDs in the --stop-position list are output
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | $MYSQL
|
|
if ($t1_final_checksum != `CHECKSUM TABLE t1`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should exclude domain 1 from stop position";
|
|
}
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Test Case 21:
|
|
--echo # Successive binary logs (e.g. logs with previous logs that have been
|
|
--echo # purged) will write events when the --start-position matches their
|
|
--echo # Gtid_list_log_event state
|
|
if ($is_remote == 1)
|
|
{
|
|
--echo #
|
|
--echo # Reset server state
|
|
RESET MASTER;
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL
|
|
FLUSH LOGS;
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL
|
|
FLUSH LOGS;
|
|
--eval PURGE BINARY LOGS TO "$BINLOG_FILE2"
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t3;
|
|
}
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | $MYSQL
|
|
if ($t3_final_checksum != `CHECKSUM TABLE t3`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should not have any events from unspecified binlog file";
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should not have any events from unspecified binlog file";
|
|
}
|
|
DROP TABLE t3;
|
|
|
|
--echo #
|
|
--echo # Test Case 22:
|
|
--echo # Successive binary logs can be called with --stop-position and
|
|
--echo # without --start-position
|
|
if ($is_remote == 1)
|
|
{
|
|
--echo #
|
|
--echo # Reset server state
|
|
RESET MASTER;
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL
|
|
FLUSH LOGS;
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL
|
|
FLUSH LOGS;
|
|
--eval PURGE BINARY LOGS TO "$BINLOG_FILE2"
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t3;
|
|
}
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --stop-position=0-1-4 | $MYSQL
|
|
if (`SELECT COUNT(*) FROM test.t3`)
|
|
{
|
|
die $data_inconsistent_err;
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`)
|
|
{
|
|
die "t1 should not exist as binlog replay should not have any events from unspecified binlog file";
|
|
}
|
|
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
|
|
{
|
|
die "t2 should not exist as binlog replay should not have any events from unspecified binlog file";
|
|
}
|
|
DROP TABLE t3;
|
|
|
|
|
|
if ($is_remote == 1)
|
|
{
|
|
--echo #
|
|
--echo # Remote-only setup for error cases
|
|
RESET MASTER;
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL
|
|
FLUSH LOGS;
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL
|
|
FLUSH LOGS;
|
|
--eval PURGE BINARY LOGS TO "$BINLOG_FILE2"
|
|
}
|
|
|
|
--echo # At the following error cases analysis
|
|
--echo # note incompatible --start-position with the value of
|
|
--echo # Gtid list event of the 2nd binlog file printed above.
|
|
|
|
--let err_out_= $MYSQLTEST_VARDIR/tmp/err.out
|
|
--let SEARCH_FILE=$err_out_
|
|
|
|
--echo #
|
|
--echo # Error Case 1:
|
|
--echo # A GTID --start-position that does not mention all domains that make
|
|
--echo # up the binary log state should error
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_
|
|
--error 1
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-3 > $tmp_out_ 2> $err_out_
|
|
if ($is_remote == 1)
|
|
{
|
|
--let SEARCH_PATTERN=ERROR: Got error reading packet from server
|
|
}
|
|
if ($is_remote == 0)
|
|
{
|
|
--let SEARCH_PATTERN=ERROR: Starting GTID position list does not specify an initial value
|
|
}
|
|
--source include/search_pattern_in_file.inc
|
|
--remove_file $err_out_
|
|
|
|
--echo #
|
|
--echo # Error Case 2:
|
|
--echo # A GTID --start-position with any sequence numbers which occur before
|
|
--echo # the binary log state should result in error
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_
|
|
--error 1
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > $tmp_out_ 2> $err_out_
|
|
if ($is_remote == 1)
|
|
{
|
|
--let SEARCH_PATTERN=ERROR: Got error reading packet from server
|
|
}
|
|
if ($is_remote == 0)
|
|
{
|
|
--let SEARCH_PATTERN=ERROR: Binary logs are missing data for domain 0
|
|
}
|
|
--source include/search_pattern_in_file.inc
|
|
--remove_file $err_out_
|
|
|
|
--echo #
|
|
--echo # Error Case 3:
|
|
--echo # A GTID --start-position with any sequence numbers that are not
|
|
--echo # eventually processed results in error
|
|
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_
|
|
--error 1
|
|
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > $tmp_out_ 2> $err_out_
|
|
if ($is_remote == 1)
|
|
{
|
|
--let SEARCH_PATTERN=ERROR: Got error reading packet from server
|
|
}
|
|
if ($is_remote == 0)
|
|
{
|
|
--let SEARCH_PATTERN=ERROR: Binary logs never reached expected GTID state
|
|
}
|
|
--source include/search_pattern_in_file.inc
|
|
--remove_file $err_out_
|
|
|
|
if ($is_remote == 1)
|
|
{
|
|
--echo #
|
|
--echo # Remote-only cleanup from error cases
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t3;
|
|
RESET MASTER;
|
|
}
|
|
|
|
--remove_file $MYSQLD_DATADIR/$BINLOG_FILE.orig
|
|
--remove_file $MYSQLD_DATADIR/$BINLOG_FILE2.orig
|
|
--remove_file $tmp_out_
|