Skip to content

Commit 73ced31

Browse files
abhinav04sharmainikep
authored andcommitted
Flushing engine logs when switching from primary to secondary
Summary: We need to make sure that we flush the engine logs (aka sync the engines) before we switch from binlog to apply log (i.e. switch from primary to secondary) to recover correctly in host restart case. Otherwise if host restarts after apply log has been created and the engine goes back in time on recovery, we'll use the apply log for recovery and assume that engine is caught up. Differential Revision: D50385170
1 parent ff9776d commit 73ced31

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sql/binlog.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12372,6 +12372,10 @@ int binlog_change_to_apply() {
1237212372
DBUG_RETURN(0);
1237312373
}
1237412374

12375+
if (ha_flush_logs()) {
12376+
DBUG_RETURN(1);
12377+
}
12378+
1237512379
int error = 0;
1237612380
LOG_INFO linfo;
1237712381
mysql_mutex_lock(mysql_bin_log.get_log_lock());
@@ -12456,7 +12460,9 @@ int binlog_change_to_binlog(THD *thd) {
1245612460
// batch of transactions. This is important because the act of switching trx
1245712461
// logs from "apply-logs-*" to "binary-logs-*" looks like a rotation to other
1245812462
// parts of the system and rotation is always a 'sync' point
12459-
ha_flush_logs(NULL);
12463+
if (ha_flush_logs()) {
12464+
DBUG_RETURN(1);
12465+
}
1246012466

1246112467
mysql_mutex_lock(mysql_bin_log.get_log_lock());
1246212468
const bool is_locked = dump_log.lock();

0 commit comments

Comments
 (0)