|
9 | 9 | # 2. Apply the new binlog file ( with database rewritten ) to a new database
|
10 | 10 | # and check if it works.
|
11 | 11 | #
|
| 12 | +# Bug26117735: MYSQLBINLOG READ-FROM-REMOTE-SERVER NOT HONORING REWRITE_DB |
| 13 | +# FILTERING |
| 14 | +# |
| 15 | +# Problem: |
| 16 | +# When running mysqlbinlog with the --read-from-remote-server option, |
| 17 | +# the processing of the binlog entries accepts rewrite_db as an argument, but |
| 18 | +# ignores the rewrite rule. Therefore no filtering is done on the binlog |
| 19 | +# entries, resulting in failures to write data in the target DB. |
| 20 | +# |
| 21 | +# Test case1: |
| 22 | +# Verify that rewrite_db filter works fine when reading binary log from remote |
| 23 | +# server. |
| 24 | +# |
| 25 | +# Test case2: |
| 26 | +# Verify that error scenario is handled properly in a case where rewrite_db |
| 27 | +# filter fails to rewrite the databases. |
| 28 | +# |
| 29 | +# mysqlbinlog should be debug compiled. |
| 30 | +--source include/mysqlbinlog_have_debug.inc |
12 | 31 | --source include/have_binlog_format_row.inc
|
13 | 32 |
|
14 | 33 | RESET MASTER;
|
@@ -42,6 +61,17 @@ DELETE FROM t1 WHERE i=2;
|
42 | 61 | --echo [VALID SYNTAX,The from->to database names is correctly mentioned]
|
43 | 62 | --exec $MYSQL_BINLOG --force-if-open --rewrite-db="db1->db2" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql
|
44 | 63 |
|
| 64 | +--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 65 | + |
| 66 | +# Bug26117735: MYSQLBINLOG READ-FROM-REMOTE-SERVER NOT HONORING REWRITE_DB FILTERING |
| 67 | +--echo [VALID SYNTAX read from remote server ,The from->to database names are correctly mentioned] |
| 68 | +--exec $MYSQL_BINLOG --force-if-open --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->db2" $binlog_file > $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql |
| 69 | + |
| 70 | +--echo [VALID SYNTAX, but during the application of rewrite_db filter an invalid event is found. Hence mysqlbinlog tool should exit with an appropriate error] |
| 71 | +--echo [ERROR: Got fatal error while applying rewrite db filter.] |
| 72 | +--error 1 |
| 73 | +--exec $MYSQL_BINLOG --force-if-open -#d,'simulate_corrupt_event_len' --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->db2" $binlog_file > $MYSQLTEST_VARDIR/tmp/tmp.sql |
| 74 | + |
45 | 75 | --echo #Dropping the database db1 and creating the table in the new database db2.
|
46 | 76 |
|
47 | 77 | CREATE DATABASE db2;
|
@@ -69,9 +99,23 @@ RESET MASTER;
|
69 | 99 | --let $assert_cond= `SELECT COUNT(*)=1 from db2.t1`
|
70 | 100 | --source include/assert.inc
|
71 | 101 |
|
| 102 | +DROP DATABASE db1; |
| 103 | +DROP DATABASE db2; |
| 104 | +CREATE DATABASE db2; |
| 105 | +# With gtid-mode=on we need purge gtid_executed, if not transactions |
| 106 | +# replayed through mysqlbinlog will be skipped. |
| 107 | +RESET MASTER; |
| 108 | +--echo [The event of table db1.t1 has been successfully applied to db2.t1] |
| 109 | +--exec $MYSQL --database=db2 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql |
| 110 | +--let $assert_text= Assert that table db2.t1 has one row after applying the sql file. |
| 111 | +--let $assert_cond= `SELECT COUNT(*)=1 from db2.t1` |
| 112 | +--source include/assert.inc |
| 113 | + |
72 | 114 | --echo CLEANUP
|
73 | 115 |
|
74 | 116 | --remove_file $MYSQLTEST_VARDIR/tmp/row_event.sql
|
75 | 117 | --remove_file $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql
|
| 118 | +--remove_file $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql |
| 119 | +--remove_file $MYSQLTEST_VARDIR/tmp/tmp.sql |
76 | 120 | DROP DATABASE db1;
|
77 | 121 | DROP DATABASE db2;
|
0 commit comments