Index: mysql-5.7.5-m15/sql/binlog.h =================================================================== --- mysql-5.7.5-m15.orig/sql/binlog.h +++ mysql-5.7.5-m15/sql/binlog.h @@ -323,7 +323,6 @@ class MYSQL_BIN_LOG: public TC_LOG char db[NAME_LEN + 1]; bool write_error, inited; IO_CACHE log_file; - volatile enum_log_state log_state; const enum cache_type io_cache_type; #ifdef HAVE_PSI_INTERFACE /** Instrumentation key to use for file io in @c log_file */ @@ -480,7 +479,7 @@ class MYSQL_BIN_LOG: public TC_LOG public: const char *generate_name(const char *log_name, const char *suffix, char *buff); - bool is_open() const { return log_state != LOG_CLOSED; } + bool is_open() { return my_atomic_load32(&log_state) != LOG_CLOSED; } /* This is relay log */ bool is_relay_log; @@ -615,6 +614,8 @@ public: previous_gtid_set_relaylog= previous_gtid_set_param; } private: + int32 log_state; /* atomic enum_log_state */ + /* The prevoius gtid set in relay log. */ Gtid_set* previous_gtid_set_relaylog; Index: mysql-5.7.5-m15/sql/binlog.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/binlog.cc +++ mysql-5.7.5-m15/sql/binlog.cc @@ -2551,7 +2551,7 @@ bool mysql_show_binlog_events(THD* thd) MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_period, enum cache_type io_cache_type_arg) :name(NULL), write_error(false), inited(false), - log_state(LOG_CLOSED), io_cache_type(io_cache_type_arg), + io_cache_type(io_cache_type_arg), #ifdef HAVE_PSI_INTERFACE m_key_LOCK_log(key_LOG_LOCK_log), #endif @@ -2563,6 +2563,7 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_ relay_log_checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF), previous_gtid_set_relaylog(0) { + my_atomic_store32(&log_state, LOG_CLOSED); /* We don't want to initialize locks here as such initialization depends on safe_mutex (when using safe_mutex) which depends on MY_INIT(), which is @@ -2902,7 +2903,7 @@ bool MYSQL_BIN_LOG::open( MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL))) goto err; - log_state= LOG_OPENED; + my_atomic_store32(&log_state, LOG_OPENED); DBUG_RETURN(0); err: @@ -2933,7 +2934,7 @@ err: end_io_cache(&log_file); my_free(name); name= NULL; - log_state= LOG_CLOSED; + my_atomic_store32(&log_state, LOG_CLOSED); DBUG_RETURN(1); } @@ -3801,7 +3802,7 @@ bool MYSQL_BIN_LOG::open_binlog(const ch #endif } - log_state= LOG_OPENED; + my_atomic_store32(&log_state, LOG_OPENED); #ifdef HAVE_REPLICATION close_purge_index_file(); @@ -3820,7 +3821,7 @@ err: end_io_cache(&index_file); my_free(name); name= NULL; - log_state= LOG_CLOSED; + my_atomic_store32(&log_state, LOG_CLOSED); if (binlogging_impossible_mode == ABORT_SERVER) { THD *thd= current_thd; @@ -6601,7 +6602,7 @@ void MYSQL_BIN_LOG::close(uint exiting) { // One can't set log_type here! DBUG_ENTER("MYSQL_BIN_LOG::close"); DBUG_PRINT("enter",("exiting: %d", (int) exiting)); - if (log_state == LOG_OPENED) + if (my_atomic_load32(&log_state) == LOG_OPENED) { #ifdef HAVE_REPLICATION if ((exiting & LOG_CLOSE_STOP_EVENT) != 0) @@ -6636,7 +6637,7 @@ void MYSQL_BIN_LOG::close(uint exiting) } /* this will cleanup IO_CACHE, sync and close the file */ - if (log_state == LOG_OPENED) + if (my_atomic_load32(&log_state) == LOG_OPENED) { end_io_cache(&log_file); @@ -6657,7 +6658,7 @@ void MYSQL_BIN_LOG::close(uint exiting) } } - log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED; + my_atomic_store32(&log_state, (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED); my_free(name); name= NULL; } @@ -6678,7 +6679,7 @@ void MYSQL_BIN_LOG::close(uint exiting) errno, my_strerror(errbuf, sizeof(errbuf), errno)); } } - log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED; + my_atomic_store32(&log_state, (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED); my_free(name); name= NULL; DBUG_VOID_RETURN;