Skip to content

Commit

Permalink
MDEV-27754 : Assertion with innodb_flush_method=O_DSYNC
Browse files Browse the repository at this point in the history
If innodb_flush_method=O_DSYNC, log_sys.flushed_to_disk_lsn  is changed
without 'flush_lock' protection inside log_write().

This leads to a race condition, if there are 2 threads running in parallel,
doing log_write_up_to() with different values for 'flush_to_disk'

In this case, log_write() and log_write_flush_to_disk_low() can execute at
the same time, and both would change flushed_lsn.

The fix is to remove special treatment of durable writes from log_write().
There is no apparent reason for this special treatment, log_write_flush_to_disk_low()
is already optimized for durable writes.

Nor there is an apparent reason to call log_flush_notify() more often in
for O_DSYNC.
  • Loading branch information
vaintroub committed Feb 7, 2022
1 parent fb40a2f commit 881918b
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,7 @@ log_write_buf(
}
}

/** Flush the recently written changes to the log file.
and invoke mysql_mutex_lock(&log_sys.mutex). */
/** Flush the recently written changes to the log file.*/
static void log_write_flush_to_disk_low(lsn_t lsn)
{
if (!log_sys.log.writes_are_durable())
Expand Down Expand Up @@ -780,10 +779,6 @@ static void log_write(bool rotate_key)
start_offset - area_start);
srv_stats.log_padded.add(pad_size);
log_sys.write_lsn = write_lsn;
if (log_sys.log.writes_are_durable()) {
log_sys.set_flushed_lsn(write_lsn);
log_flush_notify(write_lsn);
}
return;
}

Expand Down

0 comments on commit 881918b

Please sign in to comment.