Commit 594787cf authored by Luis Soares's avatar Luis Soares

BUG#57288: binlog_tmp_table fails sporadically: "Failed to write

the DROP statement ..."
      
Problem: When using temporary tables and closing a session, an
implicit DROP TEMPORARY TABLE IF EXISTS is written to the binary
log (while cleaning up the context of the session THD - see:
sql_class.cc:THD::cleanup which calls close_temporary_tables).
     
close_temporary_tables, first checks if the binary log is opened
and then proceeds to creating the DROP statements. Then, such
statements, are written to the binary log through
MYSQL_BIN_LOG::write(Log_event *). Inside, there is another check
if the binary log is opened and if not an error is returned. This
is where the faulty behavior is triggered. Given that the test
case replays a binary log, with temp tables statements, and right
after it issues RESET MASTER, there is a chance that is_open will
report false (when the mysql session is closed and the temporary
tables are written).
      
is_open may return false, because MYSQL_BIN_LOG::reset_logs is
not setting the correct flag (LOG_CLOSE_TO_BE_OPENED), on the
MYSQL_LOG_BIN::log_state (instead it sets just the
LOG_CLOSE_INDEX flag, leaving the log_state to
LOG_CLOSED). Thence, when writing the DROP statement as part of
the THD::cleanup, the thread could get a return value of false
for is_open - inside MYSQL_BIN_LOG::write, ultimately reporting
that it can't write the event to the binary log.
      
Fix: We fix this by adding the correct flag, missing in the
second close.
parent f8ee5c7b
...@@ -3037,7 +3037,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd) ...@@ -3037,7 +3037,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
} }
/* Start logging with a new file */ /* Start logging with a new file */
close(LOG_CLOSE_INDEX); close(LOG_CLOSE_INDEX | LOG_CLOSE_TO_BE_OPENED);
if ((error= my_delete_allow_opened(index_file_name, MYF(0)))) // Reset (open will update) if ((error= my_delete_allow_opened(index_file_name, MYF(0)))) // Reset (open will update)
{ {
if (my_errno == ENOENT) if (my_errno == ENOENT)
......
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