summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZicheng Huang <hzc989@outlook.com>2019-02-27 08:31:35 +0000
committerOleksandr "Sanja" Byelkin <sanja.byelkin@gmail.com>2019-06-05 13:56:27 +0200
commitd7c8423a3d44a5eb9bb22efd957eab3f32497b0f (patch)
treea14f39d1c0d194a7491b2278692bba78a1082350
parentb4287ec3865d90920f0cc440c36f4873dcf51703 (diff)
downloadmariadb-git-d7c8423a3d44a5eb9bb22efd957eab3f32497b0f.tar.gz
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
-rw-r--r--mysql-test/suite/binlog/r/flashback-largebinlog.result71
-rw-r--r--mysql-test/suite/binlog/t/flashback-largebinlog.test110
-rw-r--r--mysys/mf_iocache.c8
3 files changed, 185 insertions, 4 deletions
diff --git a/mysql-test/suite/binlog/r/flashback-largebinlog.result b/mysql-test/suite/binlog/r/flashback-largebinlog.result
new file mode 100644
index 00000000000..526204f259f
--- /dev/null
+++ b/mysql-test/suite/binlog/r/flashback-largebinlog.result
@@ -0,0 +1,71 @@
+#
+# Preparatory cleanup.
+#
+drop database if exists mysqltest;
+create database mysqltest;
+use mysqltest;
+DROP TABLE IF EXISTS t1;
+#
+# We need a fixed timestamp to avoid varying results.
+#
+SET timestamp=1000000000;
+#
+# We need big packets.
+#
+# Capture initial value to reset at the end of the test
+# Now adjust max_allowed_packet
+SET @@global.max_allowed_packet= 10*1024*1024*1024;
+Warnings:
+Warning 1292 Truncated incorrect max_allowed_packet value: '10737418240'
+max_allowed_packet is a global variable.
+In order for the preceding change in max_allowed_packets' value
+to be seen and used, we must start a new connection.
+The change does not take effect with the current one.
+For simplicity, we just disconnect / reconnect connection default here.
+disconnect default;
+connect default, localhost,root,,;
+#
+# Delete all existing binary logs.
+#
+RESET MASTER;
+#
+# Create a test table.
+#
+use mysqltest;
+CREATE TABLE t1 (
+c1 LONGTEXT
+) DEFAULT CHARSET latin1;
+#
+# Show how many rows are affected by each statement.
+#
+#
+# Insert some big rows.
+#
+insert 1024MB data twice
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 67108864));
+affected rows: 1
+INSERT INTO t1 VALUES (REPEAT('MegaByteBlckMany', 67108864));
+affected rows: 1
+#
+# Flush all log buffers to the log file.
+#
+FLUSH LOGS;
+affected rows: 0
+#
+# Call mysqlbinlog to display the log file contents.
+# NOTE: The output of mysqlbinlog is redirected to
+# $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
+# If you want to examine it, disable remove_file
+# at the bottom of the test script.
+#
+#
+# Cleanup.
+#
+# reset variable value to pass testcase checks
+SET @@global.max_allowed_packet = 16777216;
+affected rows: 0
+DROP TABLE t1;
+affected rows: 0
+drop database if exists mysqltest;
+affected rows: 0
+remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
diff --git a/mysql-test/suite/binlog/t/flashback-largebinlog.test b/mysql-test/suite/binlog/t/flashback-largebinlog.test
new file mode 100644
index 00000000000..6ff58b706d3
--- /dev/null
+++ b/mysql-test/suite/binlog/t/flashback-largebinlog.test
@@ -0,0 +1,110 @@
+# mysqlbinlog_big.test
+#
+# Show that mysqlbinlog can handle big rows.
+#
+
+#
+# The *huge* output of mysqlbinlog will be redirected to
+# $MYSQLTEST_VARDIR/$mysqlbinlog_output
+#
+--let $mysqlbinlog_output= tmp/mysqlbinlog_big_1.out
+
+--source include/have_binlog_format_row.inc
+
+--source include/have_log_bin.inc
+
+# This is a big test.
+--source include/big_test.inc
+
+--echo #
+--echo # Preparatory cleanup.
+--echo #
+--disable_warnings
+drop database if exists mysqltest;
+create database mysqltest;
+use mysqltest;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # We need a fixed timestamp to avoid varying results.
+--echo #
+SET timestamp=1000000000;
+
+--echo #
+--echo # We need big packets.
+--echo #
+--echo # Capture initial value to reset at the end of the test
+# use let $<var> = query_get_value as FLUSH statements
+# in the test will set @<var> values to NULL
+let $orig_max_allowed_packet =
+query_get_value(SELECT @@global.max_allowed_packet, @@global.max_allowed_packet, 1);
+
+--echo # Now adjust max_allowed_packet
+SET @@global.max_allowed_packet= 10*1024*1024*1024;
+
+--echo max_allowed_packet is a global variable.
+--echo In order for the preceding change in max_allowed_packets' value
+--echo to be seen and used, we must start a new connection.
+--echo The change does not take effect with the current one.
+--echo For simplicity, we just disconnect / reconnect connection default here.
+disconnect default;
+connect (default, localhost,root,,);
+
+--echo #
+--echo # Delete all existing binary logs.
+--echo #
+RESET MASTER;
+
+--echo #
+--echo # Create a test table.
+--echo #
+use mysqltest;
+eval CREATE TABLE t1 (
+ c1 LONGTEXT
+ ) DEFAULT CHARSET latin1;
+
+--echo #
+--echo # Show how many rows are affected by each statement.
+--echo #
+--enable_info
+
+--echo #
+--echo # Insert some big rows.
+--echo #
+
+--echo insert 1024MB data twice
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 67108864));
+INSERT INTO t1 VALUES (REPEAT('MegaByteBlckMany', 67108864));
+
+--echo #
+--echo # Flush all log buffers to the log file.
+--echo #
+FLUSH LOGS;
+
+--echo #
+--echo # Call mysqlbinlog to display the log file contents.
+--echo # NOTE: The output of mysqlbinlog is redirected to
+--echo # \$MYSQLTEST_VARDIR/$mysqlbinlog_output
+--echo # If you want to examine it, disable remove_file
+--echo # at the bottom of the test script.
+--echo #
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+--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 = #/
+--exec $MYSQL_BINLOG -B -v -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/$mysqlbinlog_output
+
+--echo #
+--echo # Cleanup.
+--echo #
+--echo # reset variable value to pass testcase checks
+eval SET @@global.max_allowed_packet = $orig_max_allowed_packet;
+DROP TABLE t1;
+drop database if exists mysqltest;
+
+--echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output
+#
+# NOTE: If you want to see the *huge* mysqlbinlog output, disable next line:
+#
+--remove_file $MYSQLTEST_VARDIR/$mysqlbinlog_output
+
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 92bca16c24f..d7689e204b6 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -120,6 +120,10 @@ init_functions(IO_CACHE* info)
DBUG_ASSERT(0);
break;
}
+ if (type == READ_CACHE || type == WRITE_CACHE || type == SEQ_READ_APPEND)
+ info->myflags|= MY_FULL_IO;
+ else
+ info->myflags&= ~MY_FULL_IO;
}
@@ -296,10 +300,6 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
}
info->inited=info->aio_result.pending=0;
#endif
- if (type == READ_CACHE || type == WRITE_CACHE || type == SEQ_READ_APPEND)
- info->myflags|= MY_FULL_IO;
- else
- info->myflags&= ~MY_FULL_IO;
DBUG_RETURN(0);
} /* init_io_cache */