@@ -6582,6 +6582,9 @@ int MYSQL_BIN_LOG::new_file_impl(bool need_lock_log, Format_description_log_even
65826582 @note The caller must hold LOCK_log before invoking this function.
65836583
65846584 @param mi Master_info for the IO thread.
6585+ @param need_data_lock If true, mi->data_lock will be acquired if a
6586+ rotation is needed. Otherwise, mi->data_lock must be held by the
6587+ caller.
65856588
65866589 @retval false success
65876590 @retval true error
@@ -6593,6 +6596,7 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
65936596
65946597 // Check pre-conditions
65956598 mysql_mutex_assert_owner (&LOCK_log);
6599+ mysql_mutex_assert_owner (&mi->data_lock );
65966600 DBUG_ASSERT (is_relay_log);
65976601 DBUG_ASSERT (current_thd->system_thread == SYSTEM_THREAD_SLAVE_IO);
65986602
@@ -6643,22 +6647,7 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
66436647 if ((uint) my_b_append_tell (&log_file) >
66446648 DBUG_EVALUATE_IF (" rotate_slave_debug_group" , 500 , max_size))
66456649 {
6646- /*
6647- If rotation is required we must acquire data_lock to protect
6648- description_event from clients executing FLUSH LOGS in parallel.
6649- In order do that we must release the existing LOCK_log so that we
6650- get it once again in proper locking order to avoid dead locks.
6651- i.e data_lock , LOCK_log.
6652- */
6653- mysql_mutex_unlock (&LOCK_log);
6654- mysql_mutex_lock (&mi->data_lock );
6655- mysql_mutex_lock (&LOCK_log);
66566650 error= new_file_without_locking (mi->get_mi_description_event ());
6657- /*
6658- After rotation release data_lock, we need the LOCK_log till we signal
6659- the updation.
6660- */
6661- mysql_mutex_unlock (&mi->data_lock );
66626651 }
66636652 }
66646653
@@ -6670,21 +6659,14 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
66706659
66716660bool MYSQL_BIN_LOG::append_event (Log_event* ev, Master_info *mi)
66726661{
6673- DBUG_ENTER (" MYSQL_BIN_LOG::append_event " );
6662+ DBUG_ENTER (" MYSQL_BIN_LOG::append " );
66746663
6675- mysql_mutex_assert_owner (&mi->data_lock );
6676- mysql_mutex_lock (&LOCK_log);
66776664 // check preconditions
66786665 DBUG_ASSERT (log_file.type == SEQ_READ_APPEND);
66796666 DBUG_ASSERT (is_relay_log);
66806667
6681- /*
6682- Release data_lock by holding LOCK_log, while writing into the relay log.
6683- If slave IO thread waits here for free space, we don't want
6684- SHOW SLAVE STATUS to hang on mi->data_lock. Note LOCK_log mutex is
6685- sufficient to block SQL thread when IO thread is updating relay log here.
6686- */
6687- mysql_mutex_unlock (&mi->data_lock );
6668+ // acquire locks
6669+ mysql_mutex_lock (&LOCK_log);
66886670
66896671 // write data
66906672 bool error = false ;
@@ -6697,7 +6679,6 @@ bool MYSQL_BIN_LOG::append_event(Log_event* ev, Master_info *mi)
66976679 error= true ;
66986680
66996681 mysql_mutex_unlock (&LOCK_log);
6700- mysql_mutex_lock (&mi->data_lock );
67016682 DBUG_RETURN (error);
67026683}
67036684
@@ -6706,25 +6687,11 @@ bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi)
67066687{
67076688 DBUG_ENTER (" MYSQL_BIN_LOG::append_buffer" );
67086689
6709- mysql_mutex_assert_owner (&mi->data_lock );
6710- mysql_mutex_lock (&LOCK_log);
67116690 // check preconditions
67126691 DBUG_ASSERT (log_file.type == SEQ_READ_APPEND);
67136692 DBUG_ASSERT (is_relay_log);
6714- /*
6715- Release data_lock by holding LOCK_log, while writing into the relay log.
6716- If slave IO thread waits here for free space, we don't want
6717- SHOW SLAVE STATUS to hang on mi->data_lock. Note LOCK_log mutex is
6718- sufficient to block SQL thread when IO thread is updating relay log here.
6719- */
6720- mysql_mutex_unlock (&mi->data_lock );
6721- DBUG_EXECUTE_IF (" simulate_io_thd_wait_for_disk_space" ,
6722- {
6723- const char act[]= " disk_full_reached SIGNAL parked" ;
6724- DBUG_ASSERT (opt_debug_sync_timeout > 0 );
6725- DBUG_ASSERT (!debug_sync_set_action (current_thd,
6726- STRING_WITH_LEN (act)));
6727- };);
6693+ mysql_mutex_assert_owner (&LOCK_log);
6694+
67286695 // write data
67296696 bool error= false ;
67306697 if (my_b_append (&log_file,(uchar*) buf,len) == 0 )
@@ -6735,8 +6702,6 @@ bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi)
67356702 else
67366703 error= true ;
67376704
6738- mysql_mutex_unlock (&LOCK_log);
6739- mysql_mutex_lock (&mi->data_lock );
67406705 DBUG_RETURN (error);
67416706}
67426707#endif // ifdef HAVE_REPLICATION
0 commit comments