Skip to content

Commit d7c8423

Browse files
hzc989sanja-byelkin
authored andcommitted
fix MDEV-18750: failed to flashback large-size binlog file
fix MDEV-18750: failed to flashback large-size binlog file fix mysqlbinlog flashback failure caused by reading io_cache without MY_FULL_IO flag fix MDEV-18750: mysqlbinlog flashback failure on large binlog
1 parent b4287ec commit d7c8423

File tree

3 files changed

+185
-4
lines changed

3 files changed

+185
-4
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Preparatory cleanup.
3+
#
4+
drop database if exists mysqltest;
5+
create database mysqltest;
6+
use mysqltest;
7+
DROP TABLE IF EXISTS t1;
8+
#
9+
# We need a fixed timestamp to avoid varying results.
10+
#
11+
SET timestamp=1000000000;
12+
#
13+
# We need big packets.
14+
#
15+
# Capture initial value to reset at the end of the test
16+
# Now adjust max_allowed_packet
17+
SET @@global.max_allowed_packet= 10*1024*1024*1024;
18+
Warnings:
19+
Warning 1292 Truncated incorrect max_allowed_packet value: '10737418240'
20+
max_allowed_packet is a global variable.
21+
In order for the preceding change in max_allowed_packets' value
22+
to be seen and used, we must start a new connection.
23+
The change does not take effect with the current one.
24+
For simplicity, we just disconnect / reconnect connection default here.
25+
disconnect default;
26+
connect default, localhost,root,,;
27+
#
28+
# Delete all existing binary logs.
29+
#
30+
RESET MASTER;
31+
#
32+
# Create a test table.
33+
#
34+
use mysqltest;
35+
CREATE TABLE t1 (
36+
c1 LONGTEXT
37+
) DEFAULT CHARSET latin1;
38+
#
39+
# Show how many rows are affected by each statement.
40+
#
41+
#
42+
# Insert some big rows.
43+
#
44+
insert 1024MB data twice
45+
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 67108864));
46+
affected rows: 1
47+
INSERT INTO t1 VALUES (REPEAT('MegaByteBlckMany', 67108864));
48+
affected rows: 1
49+
#
50+
# Flush all log buffers to the log file.
51+
#
52+
FLUSH LOGS;
53+
affected rows: 0
54+
#
55+
# Call mysqlbinlog to display the log file contents.
56+
# NOTE: The output of mysqlbinlog is redirected to
57+
# $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
58+
# If you want to examine it, disable remove_file
59+
# at the bottom of the test script.
60+
#
61+
#
62+
# Cleanup.
63+
#
64+
# reset variable value to pass testcase checks
65+
SET @@global.max_allowed_packet = 16777216;
66+
affected rows: 0
67+
DROP TABLE t1;
68+
affected rows: 0
69+
drop database if exists mysqltest;
70+
affected rows: 0
71+
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# mysqlbinlog_big.test
2+
#
3+
# Show that mysqlbinlog can handle big rows.
4+
#
5+
6+
#
7+
# The *huge* output of mysqlbinlog will be redirected to
8+
# $MYSQLTEST_VARDIR/$mysqlbinlog_output
9+
#
10+
--let $mysqlbinlog_output= tmp/mysqlbinlog_big_1.out
11+
12+
--source include/have_binlog_format_row.inc
13+
14+
--source include/have_log_bin.inc
15+
16+
# This is a big test.
17+
--source include/big_test.inc
18+
19+
--echo #
20+
--echo # Preparatory cleanup.
21+
--echo #
22+
--disable_warnings
23+
drop database if exists mysqltest;
24+
create database mysqltest;
25+
use mysqltest;
26+
DROP TABLE IF EXISTS t1;
27+
--enable_warnings
28+
29+
--echo #
30+
--echo # We need a fixed timestamp to avoid varying results.
31+
--echo #
32+
SET timestamp=1000000000;
33+
34+
--echo #
35+
--echo # We need big packets.
36+
--echo #
37+
--echo # Capture initial value to reset at the end of the test
38+
# use let $<var> = query_get_value as FLUSH statements
39+
# in the test will set @<var> values to NULL
40+
let $orig_max_allowed_packet =
41+
query_get_value(SELECT @@global.max_allowed_packet, @@global.max_allowed_packet, 1);
42+
43+
--echo # Now adjust max_allowed_packet
44+
SET @@global.max_allowed_packet= 10*1024*1024*1024;
45+
46+
--echo max_allowed_packet is a global variable.
47+
--echo In order for the preceding change in max_allowed_packets' value
48+
--echo to be seen and used, we must start a new connection.
49+
--echo The change does not take effect with the current one.
50+
--echo For simplicity, we just disconnect / reconnect connection default here.
51+
disconnect default;
52+
connect (default, localhost,root,,);
53+
54+
--echo #
55+
--echo # Delete all existing binary logs.
56+
--echo #
57+
RESET MASTER;
58+
59+
--echo #
60+
--echo # Create a test table.
61+
--echo #
62+
use mysqltest;
63+
eval CREATE TABLE t1 (
64+
c1 LONGTEXT
65+
) DEFAULT CHARSET latin1;
66+
67+
--echo #
68+
--echo # Show how many rows are affected by each statement.
69+
--echo #
70+
--enable_info
71+
72+
--echo #
73+
--echo # Insert some big rows.
74+
--echo #
75+
76+
--echo insert 1024MB data twice
77+
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 67108864));
78+
INSERT INTO t1 VALUES (REPEAT('MegaByteBlckMany', 67108864));
79+
80+
--echo #
81+
--echo # Flush all log buffers to the log file.
82+
--echo #
83+
FLUSH LOGS;
84+
85+
--echo #
86+
--echo # Call mysqlbinlog to display the log file contents.
87+
--echo # NOTE: The output of mysqlbinlog is redirected to
88+
--echo # \$MYSQLTEST_VARDIR/$mysqlbinlog_output
89+
--echo # If you want to examine it, disable remove_file
90+
--echo # at the bottom of the test script.
91+
--echo #
92+
let $MYSQLD_DATADIR= `select @@datadir`;
93+
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
94+
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/
95+
--exec $MYSQL_BINLOG -B -v -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/$mysqlbinlog_output
96+
97+
--echo #
98+
--echo # Cleanup.
99+
--echo #
100+
--echo # reset variable value to pass testcase checks
101+
eval SET @@global.max_allowed_packet = $orig_max_allowed_packet;
102+
DROP TABLE t1;
103+
drop database if exists mysqltest;
104+
105+
--echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output
106+
#
107+
# NOTE: If you want to see the *huge* mysqlbinlog output, disable next line:
108+
#
109+
--remove_file $MYSQLTEST_VARDIR/$mysqlbinlog_output
110+

mysys/mf_iocache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ init_functions(IO_CACHE* info)
120120
DBUG_ASSERT(0);
121121
break;
122122
}
123+
if (type == READ_CACHE || type == WRITE_CACHE || type == SEQ_READ_APPEND)
124+
info->myflags|= MY_FULL_IO;
125+
else
126+
info->myflags&= ~MY_FULL_IO;
123127
}
124128

125129

@@ -296,10 +300,6 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
296300
}
297301
info->inited=info->aio_result.pending=0;
298302
#endif
299-
if (type == READ_CACHE || type == WRITE_CACHE || type == SEQ_READ_APPEND)
300-
info->myflags|= MY_FULL_IO;
301-
else
302-
info->myflags&= ~MY_FULL_IO;
303303
DBUG_RETURN(0);
304304
} /* init_io_cache */
305305

0 commit comments

Comments
 (0)