Skip to content

Commit c0b41c8

Browse files
author
He Zhenxing
committed
Auto merge
2 parents 409ef39 + d0ffa8e commit c0b41c8

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ let $slave_param_comparison= =;
382382
let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
383383
# Flush logs every 0.1 second during 5 sec
384384
--disable_query_log
385-
let $i=50;
385+
let $i=100;
386386
while ($i) {
387387
FLUSH LOGS;
388388
dec $i;

sql/repl_failsafe.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ bool load_master_data(THD* thd)
977977
host was specified; there could have been a problem when replication
978978
started, which led to relay log's IO_CACHE to not be inited.
979979
*/
980-
if (flush_master_info(active_mi, 0))
980+
if (flush_master_info(active_mi, FALSE, FALSE))
981981
sql_print_error("Failed to flush master info file");
982982
}
983983
mysql_free_result(master_status_res);

sql/rpl_mi.cc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ file '%s')", fname);
387387
mi->rli.is_relay_log_recovery= FALSE;
388388
// now change cache READ -> WRITE - must do this before flush_master_info
389389
reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1);
390-
if ((error=test(flush_master_info(mi, 1))))
390+
if ((error=test(flush_master_info(mi, TRUE, TRUE))))
391391
sql_print_error("Failed to flush master info file");
392392
pthread_mutex_unlock(&mi->data_lock);
393393
DBUG_RETURN(error);
@@ -413,7 +413,9 @@ file '%s')", fname);
413413
1 - flush master info failed
414414
0 - all ok
415415
*/
416-
int flush_master_info(Master_info* mi, bool flush_relay_log_cache)
416+
int flush_master_info(Master_info* mi,
417+
bool flush_relay_log_cache,
418+
bool need_lock_relay_log)
417419
{
418420
IO_CACHE* file = &mi->file;
419421
char lbuf[22];
@@ -436,8 +438,19 @@ int flush_master_info(Master_info* mi, bool flush_relay_log_cache)
436438
*/
437439
if (flush_relay_log_cache)
438440
{
441+
pthread_mutex_t *log_lock= mi->rli.relay_log.get_log_lock();
439442
IO_CACHE *log_file= mi->rli.relay_log.get_log_file();
440-
if (flush_io_cache(log_file))
443+
444+
if (need_lock_relay_log)
445+
pthread_mutex_lock(log_lock);
446+
447+
safe_mutex_assert_owner(log_lock);
448+
err= flush_io_cache(log_file);
449+
450+
if (need_lock_relay_log)
451+
pthread_mutex_unlock(log_lock);
452+
453+
if (err)
441454
DBUG_RETURN(2);
442455
}
443456

sql/rpl_mi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ int init_master_info(Master_info* mi, const char* master_info_fname,
120120
bool abort_if_no_master_info_file,
121121
int thread_mask);
122122
void end_master_info(Master_info* mi);
123-
int flush_master_info(Master_info* mi, bool flush_relay_log_cache);
123+
int flush_master_info(Master_info* mi,
124+
bool flush_relay_log_cache,
125+
bool need_lock_relay_log);
124126
int change_master_server_id_cmp(ulong *id1, ulong *id2);
125127

126128
#endif /* HAVE_REPLICATION */

sql/rpl_rli.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int init_relay_log_info(Relay_log_info* rli,
121121
/*
122122
The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE.
123123
Note that the I/O thread flushes it to disk after writing every
124-
event, in flush_master_info(mi, 1).
124+
event, in flush_master_info(mi, 1, ?).
125125
*/
126126

127127
/*

sql/slave.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi)
17261726
" to the relay log, SHOW SLAVE STATUS may be"
17271727
" inaccurate");
17281728
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
1729-
if (flush_master_info(mi, 1))
1729+
if (flush_master_info(mi, TRUE, FALSE))
17301730
sql_print_error("Failed to flush master info file");
17311731
delete ev;
17321732
}
@@ -3047,7 +3047,7 @@ Stopping slave I/O thread due to out-of-memory error from master");
30473047
goto err;
30483048
}
30493049

3050-
if (flush_master_info(mi, 1))
3050+
if (flush_master_info(mi, TRUE, TRUE))
30513051
{
30523052
sql_print_error("Failed to flush master info file");
30533053
goto err;

sql/sql_repl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ bool change_master(THD* thd, Master_info* mi)
15321532
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
15331533
a slave before).
15341534
*/
1535-
if (flush_master_info(mi, 0))
1535+
if (flush_master_info(mi, FALSE, FALSE))
15361536
{
15371537
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
15381538
ret= TRUE;

0 commit comments

Comments
 (0)