MDEV-26166 replace log_write_up_to(LSN_MAX,...) with log_buffer_flush_to_disk()

Also, remove comparison lsn > flush/write lsn, prior to calling
log_write_up_to. The checks and early returns are part of this function.
This commit is contained in:
Vladislav Vaintroub 2021-07-16 11:27:41 +02:00
parent a7d880f0b0
commit fc2ec25733
8 changed files with 8 additions and 17 deletions

View File

@ -681,8 +681,7 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
static_cast<const byte*>(frame))); static_cast<const byte*>(frame)));
ut_ad(lsn); ut_ad(lsn);
ut_ad(lsn >= bpage->oldest_modification()); ut_ad(lsn >= bpage->oldest_modification());
if (lsn > log_sys.get_flushed_lsn()) log_write_up_to(lsn, true);
log_write_up_to(lsn, true);
e.request.node->space->io(e.request, bpage->physical_offset(), e_size, e.request.node->space->io(e.request, bpage->physical_offset(), e_size,
frame, bpage); frame, bpage);
} }

View File

@ -699,15 +699,6 @@ public:
/** Shut down the redo log subsystem. */ /** Shut down the redo log subsystem. */
void close(); void close();
/** Initiate a write of the log buffer to the file if needed.
@param flush whether to initiate a durable write */
inline void initiate_write(bool flush)
{
const lsn_t lsn= get_lsn();
if (!flush || get_flushed_lsn() < lsn)
log_write_up_to(lsn, flush);
}
}; };
/** Redo log system */ /** Redo log system */

View File

@ -792,6 +792,7 @@ void log_write_up_to(lsn_t lsn, bool flush_to_disk, bool rotate_key)
{ {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(!rotate_key || flush_to_disk); ut_ad(!rotate_key || flush_to_disk);
ut_ad(lsn != LSN_MAX);
if (recv_no_ibuf_operations) if (recv_no_ibuf_operations)
{ {

View File

@ -689,7 +689,7 @@ static lsn_t log_reserve_and_open(size_t len)
DEBUG_SYNC_C("log_buf_size_exceeded"); DEBUG_SYNC_C("log_buf_size_exceeded");
/* Not enough free space, do a write of the log buffer */ /* Not enough free space, do a write of the log buffer */
log_sys.initiate_write(false); log_write_up_to(log_sys.get_lsn(), false);
srv_stats.log_waits.inc(); srv_stats.log_waits.inc();

View File

@ -2989,13 +2989,13 @@ row_discard_tablespace_end(
} }
DBUG_EXECUTE_IF("ib_discard_before_commit_crash", DBUG_EXECUTE_IF("ib_discard_before_commit_crash",
log_write_up_to(LSN_MAX, true); log_buffer_flush_to_disk();
DBUG_SUICIDE();); DBUG_SUICIDE(););
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
DBUG_EXECUTE_IF("ib_discard_after_commit_crash", DBUG_EXECUTE_IF("ib_discard_after_commit_crash",
log_write_up_to(LSN_MAX, true); log_buffer_flush_to_disk();
DBUG_SUICIDE();); DBUG_SUICIDE(););
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);

View File

@ -1518,7 +1518,7 @@ srv_sync_log_buffer_in_background(void)
srv_main_thread_op_info = "flushing log"; srv_main_thread_op_info = "flushing log";
if (difftime(current_time, srv_last_log_flush_time) if (difftime(current_time, srv_last_log_flush_time)
>= srv_flush_log_at_timeout) { >= srv_flush_log_at_timeout) {
log_sys.initiate_write(true); log_buffer_flush_to_disk();
srv_last_log_flush_time = current_time; srv_last_log_flush_time = current_time;
srv_log_writes_and_flush++; srv_log_writes_and_flush++;
} }

View File

@ -331,7 +331,7 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn,
mysql_mutex_unlock(&log_sys.mutex); mysql_mutex_unlock(&log_sys.mutex);
log_make_checkpoint(); log_make_checkpoint();
log_write_up_to(LSN_MAX, true); log_buffer_flush_to_disk();
return DB_SUCCESS; return DB_SUCCESS;
} }

View File

@ -792,7 +792,7 @@ not_free:
DBUG_EXECUTE_IF("ib_undo_trunc", DBUG_EXECUTE_IF("ib_undo_trunc",
ib::info() << "ib_undo_trunc"; ib::info() << "ib_undo_trunc";
log_write_up_to(LSN_MAX, true); log_buffer_flush_to_disk();
DBUG_SUICIDE();); DBUG_SUICIDE(););
for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) {