Skip to content

Commit a59531e

Browse files
Sujatha SivakumarHery Ramilison
authored andcommitted
Merge branch 'mysql-5.6' into mysql-5.7
(cherry picked from commit 4ff18b7fa6b3826a0fbcb7fb8785ff7b2ae877ec)
1 parent 151f368 commit a59531e

File tree

7 files changed

+19
-154
lines changed

7 files changed

+19
-154
lines changed

mysql-test/suite/rpl/r/rpl_io_thd_wait_for_disk_space.result

Lines changed: 0 additions & 18 deletions
This file was deleted.

mysql-test/suite/rpl/t/rpl_io_thd_wait_for_disk_space-slave.opt

Lines changed: 0 additions & 1 deletion
This file was deleted.

mysql-test/suite/rpl/t/rpl_io_thd_wait_for_disk_space.test

Lines changed: 0 additions & 71 deletions
This file was deleted.

mysys/errors.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "mysys_err.h"
1818
#include "my_sys.h"
1919
#include "my_thread_local.h"
20-
#include "m_string.h"
2120

2221
const char *globerrs[GLOBERRS]=
2322
{
@@ -68,7 +67,6 @@ const char *globerrs[GLOBERRS]=
6867
*/
6968
void wait_for_free_space(const char *filename, int errors)
7069
{
71-
size_t time_to_sleep= MY_WAIT_FOR_USER_TO_FIX_PANIC;
7270
if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE))
7371
{
7472
char errbuf[MYSYS_STRERROR_SIZE];
@@ -82,15 +80,10 @@ void wait_for_free_space(const char *filename, int errors)
8280
}
8381
DBUG_EXECUTE_IF("simulate_no_free_space_error",
8482
{
85-
time_to_sleep= 1;
83+
(void) sleep(1);
84+
return;
8685
});
87-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space",
88-
{
89-
time_to_sleep= 1;
90-
});
91-
92-
(void) sleep(time_to_sleep);
93-
DEBUG_SYNC_C("disk_full_reached");
86+
(void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
9487
}
9588

9689
const char *get_global_errmsg(int nr)

mysys/my_write.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
4242
size_t writtenbytes;
4343
size_t sum_written= 0;
4444
uint errors= 0;
45-
size_t ToWriteCount;
4645
const size_t initial_count= Count;
4746

4847
DBUG_ENTER("my_write");
@@ -58,14 +57,11 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
5857
for (;;)
5958
{
6059
errno= 0;
61-
ToWriteCount= Count;
62-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space", { ToWriteCount= 1; });
6360
#ifdef _WIN32
64-
writtenbytes= my_win_write(Filedes, Buffer, ToWriteCount);
61+
writtenbytes= my_win_write(Filedes, Buffer, Count);
6562
#else
66-
writtenbytes= write(Filedes, Buffer, ToWriteCount);
63+
writtenbytes= write(Filedes, Buffer, Count);
6764
#endif
68-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space", { errno= ENOSPC; });
6965
DBUG_EXECUTE_IF("simulate_file_write_error",
7066
{
7167
errno= ENOSPC;

sql/binlog.cc

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -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

66716660
bool 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

sql/rpl_slave.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8423,6 +8423,9 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
84238423
direct master (an unsupported, useless setup!).
84248424
*/
84258425

8426+
mysql_mutex_lock(log_lock);
8427+
DBUG_ASSERT(lock_count == 1);
8428+
lock_count= 2;
84268429

84278430
s_id= uint4korr(buf + SERVER_ID_OFFSET);
84288431

@@ -8464,7 +8467,6 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
84648467
IGNORE_SERVER_IDS it increments mi->get_master_log_pos()
84658468
as well as rli->group_relay_log_pos.
84668469
*/
8467-
mysql_mutex_lock(log_lock);
84688470
if (!(s_id == ::server_id && !mi->rli->replicate_same_server_id) ||
84698471
(event_type != binary_log::FORMAT_DESCRIPTION_EVENT &&
84708472
event_type != binary_log::ROTATE_EVENT &&
@@ -8476,7 +8478,6 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
84768478
rli->ign_master_log_pos_end= mi->get_master_log_pos();
84778479
}
84788480
rli->relay_log.signal_update(); // the slave SQL thread needs to re-check
8479-
mysql_mutex_unlock(log_lock);
84808481
DBUG_PRINT("info", ("master_log_pos: %lu, event originating from %u server, ignored",
84818482
(ulong) mi->get_master_log_pos(), uint4korr(buf + SERVER_ID_OFFSET)));
84828483
}
@@ -8522,9 +8523,7 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
85228523
}
85238524
else
85248525
is_error= true;
8525-
mysql_mutex_lock(log_lock);
85268526
rli->ign_master_log_name_end[0]= 0; // last event is not ignored
8527-
mysql_mutex_unlock(log_lock);
85288527
if (save_buf != NULL)
85298528
buf= save_buf;
85308529
if (is_error)
@@ -8543,6 +8542,8 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
85438542
end:
85448543
if (lock_count >= 1)
85458544
mysql_mutex_unlock(&mi->data_lock);
8545+
if (lock_count >= 2)
8546+
mysql_mutex_unlock(log_lock);
85468547
DBUG_PRINT("info", ("error: %d", error));
85478548
DBUG_RETURN(error);
85488549
}

0 commit comments

Comments
 (0)