Skip to content

Commit b008499

Browse files
author
Sujatha Sivakumar
committed
Merge branch 'mysql-5.7' into mysql-trunk
2 parents a8ece28 + d1e03d6 commit b008499

7 files changed

+16
-154
lines changed

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

-18
This file was deleted.

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

-1
This file was deleted.

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

-71
This file was deleted.

mysys/errors.cc

+3-10
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "mysys_err.h"
2222
#include "my_sys.h"
2323
#include "my_thread_local.h"
24-
#include "m_string.h"
2524

2625
const char *globerrs[GLOBERRS]=
2726
{
@@ -72,7 +71,6 @@ const char *globerrs[GLOBERRS]=
7271
*/
7372
void wait_for_free_space(const char *filename, int errors)
7473
{
75-
size_t time_to_sleep= MY_WAIT_FOR_USER_TO_FIX_PANIC;
7674
if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE))
7775
{
7876
char errbuf[MYSYS_STRERROR_SIZE];
@@ -86,15 +84,10 @@ void wait_for_free_space(const char *filename, int errors)
8684
}
8785
DBUG_EXECUTE_IF("simulate_no_free_space_error",
8886
{
89-
time_to_sleep= 1;
87+
(void) sleep(1);
88+
return;
9089
});
91-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space",
92-
{
93-
time_to_sleep= 1;
94-
});
95-
96-
(void) sleep(time_to_sleep);
97-
DEBUG_SYNC_C("disk_full_reached");
90+
(void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
9891
}
9992

10093
const char *get_global_errmsg(int nr)

mysys/my_write.cc

+2-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
4646
size_t writtenbytes;
4747
size_t sum_written= 0;
4848
uint errors= 0;
49-
size_t ToWriteCount;
5049
const size_t initial_count= Count;
5150

5251
DBUG_ENTER("my_write");
@@ -62,14 +61,11 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
6261
for (;;)
6362
{
6463
errno= 0;
65-
ToWriteCount= Count;
66-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space", { ToWriteCount= 1; });
6764
#ifdef _WIN32
68-
writtenbytes= my_win_write(Filedes, Buffer, ToWriteCount);
65+
writtenbytes= my_win_write(Filedes, Buffer, Count);
6966
#else
70-
writtenbytes= write(Filedes, Buffer, ToWriteCount);
67+
writtenbytes= write(Filedes, Buffer, Count);
7168
#endif
72-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space", { errno= ENOSPC; });
7369
DBUG_EXECUTE_IF("simulate_file_write_error",
7470
{
7571
errno= ENOSPC;

sql/binlog.cc

+6-44
Original file line numberDiff line numberDiff line change
@@ -6723,6 +6723,7 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
67236723

67246724
// Check pre-conditions
67256725
mysql_mutex_assert_owner(&LOCK_log);
6726+
mysql_mutex_assert_owner(&mi->data_lock);
67266727
DBUG_ASSERT(is_relay_log);
67276728
DBUG_ASSERT(current_thd->system_thread == SYSTEM_THREAD_SLAVE_IO);
67286729

@@ -6773,22 +6774,7 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
67736774
if ((uint) my_b_append_tell(&log_file) >
67746775
DBUG_EVALUATE_IF("rotate_slave_debug_group", 500, max_size))
67756776
{
6776-
/*
6777-
If rotation is required we must acquire data_lock to protect
6778-
description_event from clients executing FLUSH LOGS in parallel.
6779-
In order do that we must release the existing LOCK_log so that we
6780-
get it once again in proper locking order to avoid dead locks.
6781-
i.e data_lock , LOCK_log.
6782-
*/
6783-
mysql_mutex_unlock(&LOCK_log);
6784-
mysql_mutex_lock(&mi->data_lock);
6785-
mysql_mutex_lock(&LOCK_log);
67866777
error= new_file_without_locking(mi->get_mi_description_event());
6787-
/*
6788-
After rotation release data_lock, we need the LOCK_log till we signal
6789-
the updation.
6790-
*/
6791-
mysql_mutex_unlock(&mi->data_lock);
67926778
}
67936779
}
67946780

@@ -6800,21 +6786,14 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
68006786

68016787
bool MYSQL_BIN_LOG::append_event(Log_event* ev, Master_info *mi)
68026788
{
6803-
DBUG_ENTER("MYSQL_BIN_LOG::append_event");
6789+
DBUG_ENTER("MYSQL_BIN_LOG::append");
68046790

6805-
mysql_mutex_assert_owner(&mi->data_lock);
6806-
mysql_mutex_lock(&LOCK_log);
68076791
// check preconditions
68086792
DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
68096793
DBUG_ASSERT(is_relay_log);
68106794

6811-
/*
6812-
Release data_lock by holding LOCK_log, while writing into the relay log.
6813-
If slave IO thread waits here for free space, we don't want
6814-
SHOW SLAVE STATUS to hang on mi->data_lock. Note LOCK_log mutex is
6815-
sufficient to block SQL thread when IO thread is updating relay log here.
6816-
*/
6817-
mysql_mutex_unlock(&mi->data_lock);
6795+
// acquire locks
6796+
mysql_mutex_lock(&LOCK_log);
68186797

68196798
// write data
68206799
bool error = false;
@@ -6827,7 +6806,6 @@ bool MYSQL_BIN_LOG::append_event(Log_event* ev, Master_info *mi)
68276806
error= true;
68286807

68296808
mysql_mutex_unlock(&LOCK_log);
6830-
mysql_mutex_lock(&mi->data_lock);
68316809
DBUG_RETURN(error);
68326810
}
68336811

@@ -6836,25 +6814,11 @@ bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi)
68366814
{
68376815
DBUG_ENTER("MYSQL_BIN_LOG::append_buffer");
68386816

6839-
mysql_mutex_assert_owner(&mi->data_lock);
6840-
mysql_mutex_lock(&LOCK_log);
68416817
// check preconditions
68426818
DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
68436819
DBUG_ASSERT(is_relay_log);
6844-
/*
6845-
Release data_lock by holding LOCK_log, while writing into the relay log.
6846-
If slave IO thread waits here for free space, we don't want
6847-
SHOW SLAVE STATUS to hang on mi->data_lock. Note LOCK_log mutex is
6848-
sufficient to block SQL thread when IO thread is updating relay log here.
6849-
*/
6850-
mysql_mutex_unlock(&mi->data_lock);
6851-
DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space",
6852-
{
6853-
const char act[]= "disk_full_reached SIGNAL parked";
6854-
DBUG_ASSERT(opt_debug_sync_timeout > 0);
6855-
DBUG_ASSERT(!debug_sync_set_action(current_thd,
6856-
STRING_WITH_LEN(act)));
6857-
};);
6820+
mysql_mutex_assert_owner(&LOCK_log);
6821+
68586822
// write data
68596823
bool error= false;
68606824
if (my_b_append(&log_file,(uchar*) buf,len) == 0)
@@ -6865,8 +6829,6 @@ bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi)
68656829
else
68666830
error= true;
68676831

6868-
mysql_mutex_unlock(&LOCK_log);
6869-
mysql_mutex_lock(&mi->data_lock);
68706832
DBUG_RETURN(error);
68716833
}
68726834
#endif // ifdef HAVE_REPLICATION

sql/rpl_slave.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -8427,6 +8427,9 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
84278427
direct master (an unsupported, useless setup!).
84288428
*/
84298429

8430+
mysql_mutex_lock(log_lock);
8431+
DBUG_ASSERT(lock_count == 1);
8432+
lock_count= 2;
84308433

84318434
s_id= uint4korr(buf + SERVER_ID_OFFSET);
84328435

@@ -8468,7 +8471,6 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
84688471
IGNORE_SERVER_IDS it increments mi->get_master_log_pos()
84698472
as well as rli->group_relay_log_pos.
84708473
*/
8471-
mysql_mutex_lock(log_lock);
84728474
if (!(s_id == ::server_id && !mi->rli->replicate_same_server_id) ||
84738475
(event_type != binary_log::FORMAT_DESCRIPTION_EVENT &&
84748476
event_type != binary_log::ROTATE_EVENT &&
@@ -8480,7 +8482,6 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
84808482
rli->ign_master_log_pos_end= mi->get_master_log_pos();
84818483
}
84828484
rli->relay_log.signal_update(); // the slave SQL thread needs to re-check
8483-
mysql_mutex_unlock(log_lock);
84848485
DBUG_PRINT("info", ("master_log_pos: %lu, event originating from %u server, ignored",
84858486
(ulong) mi->get_master_log_pos(), uint4korr(buf + SERVER_ID_OFFSET)));
84868487
}
@@ -8526,9 +8527,7 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
85268527
}
85278528
else
85288529
is_error= true;
8529-
mysql_mutex_lock(log_lock);
85308530
rli->ign_master_log_name_end[0]= 0; // last event is not ignored
8531-
mysql_mutex_unlock(log_lock);
85328531
if (save_buf != NULL)
85338532
buf= save_buf;
85348533
if (is_error)
@@ -8547,6 +8546,8 @@ bool queue_event(Master_info* mi,const char* buf, ulong event_len)
85478546
end:
85488547
if (lock_count >= 1)
85498548
mysql_mutex_unlock(&mi->data_lock);
8549+
if (lock_count >= 2)
8550+
mysql_mutex_unlock(log_lock);
85508551
DBUG_PRINT("info", ("error: %d", error));
85518552
DBUG_RETURN(error);
85528553
}

0 commit comments

Comments
 (0)