Commit 7effcb8e authored by Sujatha's avatar Sujatha

MDEV-23846: O_TMPFILE error in mysqlbinlog stream output breaks restore

Problem:
========
When O_TMPFILE is not supported mysqlbinlog outputs the error to standard
stream as a warning which breaks PITR:

ERROR 1064 (42000) at line 382: You have an error in your SQL syntax; check
the manual that corresponds to your MariaDB server version for the right
syntax to use near 'mysqlbinlog: O_TMPFILE is not supported on /tmp (disabling
    future attempts)

Analysis:
=========
'mysqlbinlog' utility is used to perform point-in-time-recovery based on binary
log. It converts the events in the binary log files, from binary format to text
so that they can be viewed or applied. This output can be saved to a file and
it can be sourced back to mysql client. The mysqlbinlog utility stores the
text output into IO_CACHE and when it is full the data is written to a temp
file.  The temporary file creation is attempted using 'O_TMPFILE' flag. If the
underlying filesystem doesn't support this operation, a note is printed on to
standard error and file creation is done without O_TMPFILE' flag. If standard
error is redirected to standard output the note gets written to the sql file
as shown below.

/bld/client/mysqlbinlog: O_TMPFILE is not supported on /tmp (disabling future
    attempts)
table id 32

When the sql file is used for PITR, it leads to a syntax error as it is not a
valid sql command.

Fix:
====
Make 'my_message_stderr' to ignore messages which are flagged as ME_NOTE and
ME_ERROR_LOG_ONLY. ME_ERROR_LOG_ONLY flag is applicable to server. In order to
print an informational note to stderr stream, ME_NOTE flag without
ME_ERROR_LOG_ONLY flag should be specified. 'my_message_stderr' should print
messages flagged with ME_WARNING or ME_FATAL to stderr stream.
parent 031e1427
RESET MASTER;
CREATE TABLE t(f text);
INSERT INTO t VALUES (repeat('x',4096));
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
SELECT COUNT(*) FROM t;
COUNT(*)
512
FLUSH LOGS;
DROP TABLE t;
# 512- Rows must be present
include/assert.inc [Table t should have 512 rows.]
DROP TABLE t;
RESET MASTER;
# ==== Purpose ====
#
# Suppress the following informational note that gets printed to standard
# error when O_TMPFILE flag is not supported by underlying operating system.
#
# Note: ../client/mysqlbinlog: O_TMPFILE is not supported on /tmp (disabling
# future attempts)
#
# Step 1: Generate a binarylog file with a size greater than 1MB.
# Step 2: Use mysqlbinlog tool to generate sql file and redirect the standard
# error to standard output (2>&1)
# Step 3: Source the generated sql file as inpurt to mysql client, observe no
# syntax error is reported.
#
# ==== References ====
#
# MDEV-23846: O_TMPFILE error in mysqlbinlog stream output breaks restore
#
--source include/have_binlog_format_row.inc
RESET MASTER;
CREATE TABLE t(f text);
INSERT INTO t VALUES (repeat('x',4096));
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t;
SELECT COUNT(*) FROM t;
FLUSH LOGS;
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql 2>&1
#
# Clear database and restore from binlog
#
DROP TABLE t;
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
--echo # 512- Rows must be present
--let $assert_cond= COUNT(*) = 512 FROM t
--let $assert_text= Table t should have 512 rows.
--source include/assert.inc
DROP TABLE t;
RESET MASTER;
...@@ -21,6 +21,8 @@ void my_message_stderr(uint error __attribute__((unused)), ...@@ -21,6 +21,8 @@ void my_message_stderr(uint error __attribute__((unused)),
DBUG_ENTER("my_message_stderr"); DBUG_ENTER("my_message_stderr");
DBUG_PRINT("enter",("message: %s",str)); DBUG_PRINT("enter",("message: %s",str));
(void) fflush(stdout); (void) fflush(stdout);
if (MyFlags & (ME_NOTE | ME_ERROR_LOG_ONLY))
DBUG_VOID_RETURN;
if (MyFlags & ME_BELL) if (MyFlags & ME_BELL)
(void) fputc('\007', stderr); (void) fputc('\007', stderr);
if (my_progname) if (my_progname)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment