Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1544,13 +1544,14 @@ void log_t::persist(lsn_t lsn) noexcept
ut_ad(!write_lock.is_owner());
ut_ad(!flush_lock.is_owner());
ut_ad(latch_have_wr());
ut_ad(is_opened() == archive);

lsn_t old= flushed_to_disk_lsn.load(std::memory_order_relaxed);

if (old > lsn)
return;
Comment on lines 1550 to 1551
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If old == lsn, the log has already been successfully flushed to disk up to lsn. Proceeding further with start == end (a 0-byte write) is redundant and incurs unnecessary overhead. Changing the condition to old >= lsn allows an early return in this case, improving efficiency.

  if (old >= lsn)
    return;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a valid comment. However, it is a separate issue and should probably be fixed in the earliest applicable branch (10.11).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that this change was intentionally made in #4405. If I reverted that change as suggested, we would get assertion failures in innodb.log_archive,mmap shutdown like this:

mariadbd: /mariadb/main/storage/innobase/mtr/mtr0mtr.cc:1317: static void log_t::append(byte*&, const void*, size_t): Assertion `log_sys.is_mmap() ? ((d >= log_sys.buf && d + size <= log_sys.buf + log_sys.file_size) || (log_sys.archive && d >= log_sys.resize_buf && d + size <= log_sys.resize_buf + log_sys.resize_target)) : (d >= log_sys.buf && d + size <= log_sys.buf + log_sys.buf_size)' failed.

I filed MDEV-39781 to capture this.


ut_ad(is_mmap_writeable());
ut_ad(is_opened() == archive);
const size_t start(calc_lsn_offset(old));
const size_t end(calc_lsn_offset(lsn));

Expand Down
Loading