diff --git a/plugin/semisync/semisync_master_ack_receiver.cc b/plugin/semisync/semisync_master_ack_receiver.cc index 7813807..cbef690 100644 --- a/plugin/semisync/semisync_master_ack_receiver.cc +++ b/plugin/semisync/semisync_master_ack_receiver.cc @@ -220,6 +220,7 @@ void Ack_receiver::run() fd_set read_fds; my_socket max_fd= INVALID_SOCKET; uint i; + time_t last_sched_ts= time(0); sql_print_information("Starting ack receiver thread"); @@ -294,6 +295,18 @@ void Ack_receiver::run() i++; } mysql_mutex_unlock(&m_mutex); + + /* + Locking m_mutex in while will starve other threads. + Sleep 1us per second, so other threads can catch the m_mutex easily. + */ + time_t now= time(0); + bool time_to_sched= ((ulonglong)(now - last_sched_ts) >= (ulonglong)(1)); + if (time_to_sched) + { + last_sched_ts= time(0); + my_sleep(1); + } } end: sql_print_information("Stopping ack receiver thread");