summaryrefslogtreecommitdiff
path: root/sql/log.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-10-26 17:20:20 +0300
committerMonty <monty@mariadb.org>2017-12-18 13:43:37 +0200
commit13770edbcb181f06315dab659b592edf6355efc6 (patch)
treee8396cf9215200b50b88a08530f6c7e64dd6dce3 /sql/log.h
parentea37c129f968593e48170e489788cc481fe9a2bd (diff)
downloadmariadb-git-13770edbcb181f06315dab659b592edf6355efc6.tar.gz
Changed from using LOCK_log to LOCK_binlog_end_pos for binary log
Part of MDEV-13073 AliSQL Optimize performance of semisync The idea it to use a dedicated lock detecting if there is new data in the master's binary log instead of the overused LOCK_log. Changes: - Use dedicated COND variables for the relay and binary log signaling. This was needed as we where the old 'update_cond' variable was used with different mutex's, which could cause deadlocks. - Relay log uses now COND_relay_log_updated and LOCK_log - Binary log uses now COND_bin_log_updated and LOCK_binlog_end_pos - Renamed signal_cnt to relay_signal_cnt (as we now have two signals) - Added some missing error handling in MYSQL_BIN_LOG::new_file_impl() - Reformatted some comments with old style - Renamed m_key_LOCK_binlog_end_pos to key_LOCK_binlog_end_pos - Changed 'signal_update()' to update_binlog_end_pos() which works for both relay and binary log
Diffstat (limited to 'sql/log.h')
-rw-r--r--sql/log.h85
1 files changed, 59 insertions, 26 deletions
diff --git a/sql/log.h b/sql/log.h
index dffb6a80d54..0a82f8813f0 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -425,8 +425,10 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
#ifdef HAVE_PSI_INTERFACE
/** The instrumentation key to use for @ LOCK_index. */
PSI_mutex_key m_key_LOCK_index;
- /** The instrumentation key to use for @ update_cond. */
- PSI_cond_key m_key_update_cond;
+ /** The instrumentation key to use for @ COND_relay_log_updated */
+ PSI_cond_key m_key_relay_log_update;
+ /** The instrumentation key to use for @ COND_bin_log_updated */
+ PSI_cond_key m_key_bin_log_update;
/** The instrumentation key to use for opening the log file. */
PSI_file_key m_key_file_log;
/** The instrumentation key to use for opening the log index file. */
@@ -488,7 +490,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
mysql_mutex_t LOCK_binlog_end_pos;
mysql_mutex_t LOCK_xid_list;
mysql_cond_t COND_xid_list;
- mysql_cond_t update_cond;
+ mysql_cond_t COND_relay_log_updated, COND_bin_log_updated;
ulonglong bytes_written;
IO_CACHE index_file;
char index_file_name[FN_REFLEN];
@@ -598,7 +600,7 @@ public:
/* This is relay log */
bool is_relay_log;
- ulong signal_cnt; // update of the counter is checked by heartbeat
+ ulong relay_signal_cnt; // update of the counter is checked by heartbeat
enum enum_binlog_checksum_alg checksum_alg_reset; // to contain a new value when binlog is rotated
/*
Holds the last seen in Relay-Log FD's checksum alg value.
@@ -661,13 +663,15 @@ public:
#ifdef HAVE_PSI_INTERFACE
void set_psi_keys(PSI_mutex_key key_LOCK_index,
- PSI_cond_key key_update_cond,
+ PSI_cond_key key_relay_log_update,
+ PSI_cond_key key_bin_log_update,
PSI_file_key key_file_log,
PSI_file_key key_file_log_index,
PSI_file_key key_COND_queue_busy)
{
m_key_LOCK_index= key_LOCK_index;
- m_key_update_cond= key_update_cond;
+ m_key_relay_log_update= key_relay_log_update;
+ m_key_bin_log_update= key_bin_log_update;
m_key_file_log= key_file_log;
m_key_file_log_index= key_file_log_index;
m_key_COND_queue_busy= key_COND_queue_busy;
@@ -707,7 +711,53 @@ public:
DBUG_VOID_RETURN;
}
void set_max_size(ulong max_size_arg);
- void signal_update();
+
+ /* Handle signaling that relay has been updated */
+ void signal_relay_log_update()
+ {
+ mysql_mutex_assert_owner(&LOCK_log);
+ DBUG_ASSERT(is_relay_log);
+ DBUG_ENTER("MYSQL_BIN_LOG::signal_relay_log_update");
+ relay_signal_cnt++;
+ mysql_cond_broadcast(&COND_relay_log_updated);
+ DBUG_VOID_RETURN;
+ }
+ void signal_bin_log_update()
+ {
+ mysql_mutex_assert_owner(&LOCK_binlog_end_pos);
+ DBUG_ASSERT(!is_relay_log);
+ DBUG_ENTER("MYSQL_BIN_LOG::signal_bin_log_update");
+ mysql_cond_broadcast(&COND_bin_log_updated);
+ DBUG_VOID_RETURN;
+ }
+ void update_binlog_end_pos()
+ {
+ if (is_relay_log)
+ signal_relay_log_update();
+ else
+ {
+ lock_binlog_end_pos();
+ binlog_end_pos= my_b_safe_tell(&log_file);
+ signal_bin_log_update();
+ unlock_binlog_end_pos();
+ }
+ }
+ void update_binlog_end_pos(my_off_t pos)
+ {
+ mysql_mutex_assert_owner(&LOCK_log);
+ mysql_mutex_assert_not_owner(&LOCK_binlog_end_pos);
+ lock_binlog_end_pos();
+ /*
+ Note: it would make more sense to assert(pos > binlog_end_pos)
+ but there are two places triggered by mtr that has pos == binlog_end_pos
+ i didn't investigate but accepted as it should do no harm
+ */
+ DBUG_ASSERT(pos >= binlog_end_pos);
+ binlog_end_pos= pos;
+ signal_bin_log_update();
+ unlock_binlog_end_pos();
+ }
+
void wait_for_sufficient_commits();
void binlog_trigger_immediate_group_commit();
void wait_for_update_relay_log(THD* thd);
@@ -807,7 +857,7 @@ public:
inline char* get_log_fname() { return log_file_name; }
inline char* get_name() { return name; }
inline mysql_mutex_t* get_log_lock() { return &LOCK_log; }
- inline mysql_cond_t* get_log_cond() { return &update_cond; }
+ inline mysql_cond_t* get_bin_log_cond() { return &COND_bin_log_updated; }
inline IO_CACHE* get_log_file() { return &log_file; }
inline void lock_index() { mysql_mutex_lock(&LOCK_index);}
@@ -831,23 +881,6 @@ public:
bool check_strict_gtid_sequence(uint32 domain_id, uint32 server_id,
uint64 seq_no);
-
- void update_binlog_end_pos(my_off_t pos)
- {
- mysql_mutex_assert_owner(&LOCK_log);
- mysql_mutex_assert_not_owner(&LOCK_binlog_end_pos);
- lock_binlog_end_pos();
- /**
- * note: it would make more sense to assert(pos > binlog_end_pos)
- * but there are two places triggered by mtr that has pos == binlog_end_pos
- * i didn't investigate but accepted as it should do no harm
- */
- DBUG_ASSERT(pos >= binlog_end_pos);
- binlog_end_pos= pos;
- signal_update();
- unlock_binlog_end_pos();
- }
-
/**
* used when opening new file, and binlog_end_pos moves backwards
*/
@@ -858,7 +891,7 @@ public:
lock_binlog_end_pos();
binlog_end_pos= pos;
strcpy(binlog_end_pos_file, file_name);
- signal_update();
+ signal_bin_log_update();
unlock_binlog_end_pos();
}