From 2c032b990e4ec470fad2e9f61cf6267a68b7e937 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Nov 2013 13:33:20 +0100 Subject: [PATCH] MDEV-4983: Do not leave stale master-bin.state binlog state file Attempt to read the master-bin.state file always, even if the binlog files (master-bin.index and master-bin.XXXXXX) have been deleted. This allows to easily preserve the binlog state when provisioning a new server from a copy of an old one, without needing to copy over the binlog files themselves. --- sql/log.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/log.cc b/sql/log.cc index a0845106fad..ee7e22cbe0c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -9209,10 +9209,16 @@ MYSQL_BIN_LOG::do_binlog_recovery(const char *opt_name, bool do_xa_recovery) if ((error= find_log_pos(&log_info, NullS, 1))) { + /* + If there are no binlog files (LOG_INFO_EOF), then we still try to read + the .state file to restore the binlog state. This allows to copy a server + to provision a new one without copying the binlog files (except the + master-bin.state file) and still preserve the correct binlog state. + */ if (error != LOG_INFO_EOF) sql_print_error("find_log_pos() failed (error: %d)", error); else - error= 0; + error= read_state_from_file(); return error; }