Debian Codegraph @

mysql-test/suite/binlog/t/binlog_mysqlbinlog_raw.test

raw
1 ###############################################################################
2 # Bug#24609402 MYSQLBINLOG --RAW DOES NOT GET ALL LATEST EVENTS
3 #
4 # Problem: When mysqlbinlog is used with --raw option, output file
5 # is not getting flushed till the process is completed.
6 # With --stop-never option (mysqlbinlog process never completes),
7 # output file will never contain any event.
8 #
9 # Steps to reproduce:
10 # 1) Execute some dummy statements(a create and an insert).
11 # 2) Execute MYSQL_BINLOG with --stop-never and --raw option
12 # and backup the binlog content.
13 # 3) Wait till server dump thread transfers all the data.
14 # 4) Copy binary log file that is downloaded till now before
15 # stopping dump thread that is serving mysqlbinlog
16 # --stop-never process.
17 # 5) kill the dump thread (serving the mysqlbinlog process).
18 # 6) Clean up the data on the server (a drop and a reset).
19 # 7) Apply binlog content (binlog from Step-2).
20 # 8) Check that table and the data in it exists (data from step-1).
21 # 9) Cleanup the server.
22 #
23 # This test case was extended to also test with compressed protocol. (WL#2726)
24 ###############################################################################
25
26 # Running MYSQL_BINLOG in a separate shell does not work properly in windows
27 # due to MTR limitation.
28 --source include/not_windows.inc
29
30 # Test is not specific to any binlog format. Hence Running only for 'row'.
31 --source include/have_binlog_format_row.inc
32
33 --echo # Preparing script without compression
34 --write_file $MYSQL_TMP_DIR/mysqlbinlog_raw_nocompression.sh
35 (`$MYSQL_BINLOG --raw --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --result-file=$MYSQL_TMP_DIR/ binlog.000001`) < /dev/null > /dev/null 2>&1 &
36 EOF
37
38 --echo # Testing with compressed protocol now
39 --write_file $MYSQL_TMP_DIR/mysqlbinlog_raw_compression.sh
40 (`$MYSQL_BINLOG --compress --raw --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --result-file=$MYSQL_TMP_DIR/ binlog.000001`) < /dev/null > /dev/null 2>&1 &
41 EOF
42
43 --let $iteration=2
44 while ($iteration>0)
45 {
46 # prepare the shell script
47 if ($iteration==2)
48 {
49 --let $script= $MYSQL_TMP_DIR/mysqlbinlog_raw_nocompression.sh
50 }
51
52 if ($iteration==1)
53 {
54 --let $script= $MYSQL_TMP_DIR/mysqlbinlog_raw_compression.sh
55 }
56
57 # binlog file name is needed in the test. To use binlog.000001,
58 # RESET MASTER is needed.
59 RESET MASTER;
60 # kill the dump threads if there any dump threads (may be from previous test)
61 --source include/stop_dump_threads.inc
62
63 --echo # Step-1: Execute some dummy statements.
64 CREATE TABLE t1(i int);
65 INSERT INTO t1 values (1);
66
67 --echo # Step-2: Execute MYSQL_BINLOG with --stop-never and --raw option.
68 --exec /bin/bash $script
69
70 --echo # Step-3: Wait till dump thread transfer is completed.
71 let $wait_condition= SELECT id from information_schema.processlist where processlist.command like '%Binlog%' and state like '%Source has sent%';
72 --source include/wait_condition.inc
73
74 --echo # Step-4: copy binary log file that is downloaded till now before
75 --echo # stopping dump thread that is serving mysqlbinlog
76 --echo # --stop-never process.
77 --copy_file $MYSQL_TMP_DIR/binlog.000001 $MYSQL_TMP_DIR/binlog-back_up_file.000001
78
79 --echo # Step-5: kill the dump thread serving the mysqlbinlog --stop-never process
80 --source include/stop_dump_threads.inc
81
82 --echo # Step-6: Cleanup the data, so that it is ready for reapply.
83 DROP TABLE t1;
84 RESET MASTER;
85
86 --echo # Step-7: Apply the data that we got from --stop-never process.
87 --exec $MYSQL_BINLOG $MYSQL_TMP_DIR/binlog-back_up_file.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT
88
89 --echo # Step-8: Check that the data is there.
90 --let $assert_text= Check the table t1 exists and contains one tuple with value 1.
91 --let $assert_cond= [SELECT COUNT(*) AS Val FROM t1 WHERE i = 1, Val, 1] = 1
92 --source include/assert.inc
93
94 --echo # Step-9: Cleanup
95 DROP TABLE t1;
96 --remove_file $script
97 --remove_file $MYSQL_TMP_DIR/binlog.000001
98 --remove_file $MYSQL_TMP_DIR/binlog-back_up_file.000001
99
100 --dec $iteration
101 }
102
103 #
104 # WL#2726: Allow compression when using mysqlbinlog against remote server
105 #
106
107 # test the new compression option
108 RESET MASTER;
109 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
110
111 CREATE TABLE t1(i int);
112 INSERT INTO t1 values (1);
113 DROP TABLE t1;
114
115 --echo # test mysqlbinlog '-C' option with --raw
116 --exec $MYSQL_BINLOG --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --result-file=$MYSQL_TMP_DIR/ $binlog_file < /dev/null > /dev/null 2>&1
117 --remove_file $MYSQL_TMP_DIR/$binlog_file
118 --exec $MYSQL_BINLOG --compress --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --result-file=$MYSQL_TMP_DIR/ $binlog_file < /dev/null > /dev/null 2>&1
119 --remove_file $MYSQL_TMP_DIR/$binlog_file
120 --exec $MYSQL_BINLOG -C --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --result-file=$MYSQL_TMP_DIR/ $binlog_file < /dev/null > /dev/null 2>&1
121 --remove_file $MYSQL_TMP_DIR/$binlog_file
122
123 --echo # test mysqlbinlog '--compress' option without --raw
124 --exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file < /dev/null > /dev/null 2>&1
125 --exec $MYSQL_BINLOG --compress --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file < /dev/null > /dev/null 2>&1
126 --exec $MYSQL_BINLOG -C --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file < /dev/null > /dev/null 2>&1
127
128 RESET MASTER;