File: binlog_mysqlbinlog_raw.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (128 lines) | stat: -rw-r--r-- 5,780 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
###############################################################################
# Bug#24609402 MYSQLBINLOG --RAW DOES NOT GET ALL LATEST EVENTS
#
# Problem: When mysqlbinlog is used with --raw option, output file
#          is not getting flushed till the process is completed.
#          With --stop-never option (mysqlbinlog process never completes),
#          output file will never contain any event.
#
# Steps to reproduce:
#          1) Execute some dummy statements(a create and an insert).
#          2) Execute MYSQL_BINLOG with --stop-never and --raw option
#             and backup the binlog content.
#          3) Wait till server dump thread transfers all the data.
#          4) Copy binary log file that is downloaded till now before
#             stopping dump thread that is serving mysqlbinlog
#             --stop-never process.
#          5) kill the dump thread (serving the mysqlbinlog process).
#          6) Clean up the data on the server (a drop and a reset).
#          7) Apply binlog content (binlog from Step-2).
#          8) Check that table and the data in it exists (data from step-1).
#          9) Cleanup the server.
#
# This test case was extended to also test with compressed protocol. (WL#2726)
###############################################################################

# Running MYSQL_BINLOG in a separate shell does not work properly in windows
# due to MTR limitation.
--source include/not_windows.inc

# Test is not specific to any binlog format. Hence Running only for 'row'.
--source include/have_binlog_format_row.inc

--echo # Preparing script without compression
--write_file $MYSQL_TMP_DIR/mysqlbinlog_raw_nocompression.sh
(`$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 &
EOF

--echo # Testing with compressed protocol now
--write_file $MYSQL_TMP_DIR/mysqlbinlog_raw_compression.sh
(`$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 &
EOF

--let $iteration=2
while ($iteration>0)
{
  # prepare the shell script
  if ($iteration==2)
  {
    --let $script= $MYSQL_TMP_DIR/mysqlbinlog_raw_nocompression.sh
  }

  if ($iteration==1)
  {
    --let $script= $MYSQL_TMP_DIR/mysqlbinlog_raw_compression.sh
  }

  # binlog file name is needed in the test. To use binlog.000001,
  # RESET MASTER is needed.
  RESET MASTER;
  # kill the dump threads if there any dump threads (may be from previous test)
  --source include/stop_dump_threads.inc

  --echo # Step-1: Execute some dummy statements.
  CREATE TABLE t1(i int);
  INSERT INTO t1 values (1);

  --echo # Step-2: Execute MYSQL_BINLOG with --stop-never and --raw option.
  --exec /bin/bash $script

  --echo # Step-3: Wait till dump thread transfer is completed.
  let $wait_condition= SELECT id from information_schema.processlist where processlist.command like '%Binlog%' and state like '%Source has sent%';
  --source include/wait_condition.inc

  --echo # Step-4: copy binary log file that is downloaded till now before
  --echo #         stopping dump thread that is serving mysqlbinlog
  --echo #         --stop-never process.
  --copy_file $MYSQL_TMP_DIR/binlog.000001 $MYSQL_TMP_DIR/binlog-back_up_file.000001

  --echo # Step-5: kill the dump thread serving the mysqlbinlog --stop-never process
  --source include/stop_dump_threads.inc

  --echo # Step-6: Cleanup the data, so that it is ready for reapply.
  DROP TABLE t1;
  RESET MASTER;

  --echo # Step-7: Apply the data that we got from --stop-never process.
  --exec $MYSQL_BINLOG $MYSQL_TMP_DIR/binlog-back_up_file.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT

  --echo # Step-8: Check that the data is there.
  --let $assert_text= Check the table t1 exists and contains one tuple with value 1.
  --let $assert_cond= [SELECT COUNT(*) AS Val FROM t1 WHERE i = 1, Val, 1] = 1
  --source include/assert.inc

  --echo # Step-9: Cleanup
  DROP TABLE t1;
  --remove_file $script
  --remove_file $MYSQL_TMP_DIR/binlog.000001
  --remove_file $MYSQL_TMP_DIR/binlog-back_up_file.000001

  --dec $iteration
}

#
# WL#2726: Allow compression when using mysqlbinlog against remote server
#

# test the new compression option
RESET MASTER;
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)

CREATE TABLE t1(i int);
INSERT INTO t1 values (1);
DROP TABLE t1;

--echo # test mysqlbinlog '-C' option with --raw
--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
--remove_file $MYSQL_TMP_DIR/$binlog_file
--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
--remove_file $MYSQL_TMP_DIR/$binlog_file
--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
--remove_file $MYSQL_TMP_DIR/$binlog_file

--echo # test mysqlbinlog '--compress' option without --raw
--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
--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
--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

RESET MASTER;