Skip to content

Commit 6dd801d

Browse files
author
Luis Soares
committed
BUG#50364: manual merge to mysql-next-mr-bugfixing.
Conflicts ========= Text conflict in sql/repl_failsafe.cc Additional changes ================== Replace references to pthread_mutex with mysql_mutex
2 parents ac8e3fe + d0ffa8e commit 6dd801d

File tree

6 files changed

+25
-10
lines changed

6 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/rpl_mi.cc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ file '%s')", fname);
369369
mi->rli.is_relay_log_recovery= FALSE;
370370
// now change cache READ -> WRITE - must do this before flush_master_info
371371
reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1);
372-
if ((error=test(flush_master_info(mi, 1))))
372+
if ((error=test(flush_master_info(mi, TRUE, TRUE))))
373373
sql_print_error("Failed to flush master info file");
374374
mysql_mutex_unlock(&mi->data_lock);
375375
DBUG_RETURN(error);
@@ -395,7 +395,9 @@ file '%s')", fname);
395395
1 - flush master info failed
396396
0 - all ok
397397
*/
398-
int flush_master_info(Master_info* mi, bool flush_relay_log_cache)
398+
int flush_master_info(Master_info* mi,
399+
bool flush_relay_log_cache,
400+
bool need_lock_relay_log)
399401
{
400402
IO_CACHE* file = &mi->file;
401403
char lbuf[22];
@@ -418,8 +420,19 @@ int flush_master_info(Master_info* mi, bool flush_relay_log_cache)
418420
*/
419421
if (flush_relay_log_cache)
420422
{
423+
mysql_mutex_t *log_lock= mi->rli.relay_log.get_log_lock();
421424
IO_CACHE *log_file= mi->rli.relay_log.get_log_file();
422-
if (flush_io_cache(log_file))
425+
426+
if (need_lock_relay_log)
427+
mysql_mutex_lock(log_lock);
428+
429+
mysql_mutex_assert_owner(log_lock);
430+
err= flush_io_cache(log_file);
431+
432+
if (need_lock_relay_log)
433+
mysql_mutex_unlock(log_lock);
434+
435+
if (err)
423436
DBUG_RETURN(2);
424437
}
425438

sql/rpl_mi.h

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

125127
#endif /* HAVE_REPLICATION */

sql/rpl_rli.cc

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

129129
/*

sql/slave.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
510510
DBUG_PRINT("info",("Flushing relay log and master info file."));
511511
if (current_thd)
512512
thd_proc_info(current_thd, "Flushing relay log and master info files.");
513-
if (flush_master_info(mi, TRUE /* flush relay log */))
513+
if (flush_master_info(mi, TRUE, FALSE))
514514
DBUG_RETURN(ER_ERROR_DURING_FLUSH_LOGS);
515515

516516
if (my_sync(mi->rli.relay_log.get_log_file()->file, MYF(MY_WME)))
@@ -1601,7 +1601,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi)
16011601
" to the relay log, SHOW SLAVE STATUS may be"
16021602
" inaccurate");
16031603
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
1604-
if (flush_master_info(mi, 1))
1604+
if (flush_master_info(mi, TRUE, FALSE))
16051605
sql_print_error("Failed to flush master info file");
16061606
delete ev;
16071607
}
@@ -2928,7 +2928,7 @@ Stopping slave I/O thread due to out-of-memory error from master");
29282928
goto err;
29292929
}
29302930

2931-
if (flush_master_info(mi, 1))
2931+
if (flush_master_info(mi, TRUE, TRUE))
29322932
{
29332933
sql_print_error("Failed to flush master info file");
29342934
goto err;

sql/sql_repl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ bool change_master(THD* thd, Master_info* mi)
15221522
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
15231523
a slave before).
15241524
*/
1525-
if (flush_master_info(mi, 0))
1525+
if (flush_master_info(mi, FALSE, FALSE))
15261526
{
15271527
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
15281528
ret= TRUE;

0 commit comments

Comments
 (0)