Skip to content
/ server Public

MDEV-38968 Redundant FILE_CHECKPOINT writes#4747

Draft
dr-m wants to merge 2 commits into10.11from
MDEV-38968
Draft

MDEV-38968 Redundant FILE_CHECKPOINT writes#4747
dr-m wants to merge 2 commits into10.11from
MDEV-38968

Conversation

@dr-m
Copy link
Contributor

@dr-m dr-m commented Mar 6, 2026

  • The Jira issue number for this PR is: MDEV-38968

Description

Concurrent calls to log_checkpoint_low() were possible from multiple threads, and they could cause redundant writes of FILE_CHECKPOINT records. Let us simplify the logic by making the dedicated buf_flush_page_cleaner() thread responsible for checkpoints.

log_t::write_checkpoint(lsn_t end_lsn): Add the parameter checkpoint, which replaces log_sys.next_checkpoint_lsn.

log_sys.checkpoint_pending: Remove. Only the buf_flush_page_cleaner thread will write checkpoints, hence there is no possibility of a race condition.

log_checkpoint_low(), log_checkpoint(): Remove the return value, because there cannot be any concurrent log checkpoint in progress.

buf_flush_wait(): Add special handling for log_sys.check_for_checkpoint() as well as shutdown.

buf_flush_wait_flushed(): Assert that buf_flush_page_cleaner() is available.

log_make_checkpoint(): Delegate all work to the page cleaner.

buf_flush_sync_for_checkpoint(): Update the systemd watchdog. On shutdown, keep flushing until a checkpoint has been written.

buf_flush_page_cleaner(): Revise the shutdown logic so that all changes will be written out.

buf_flush_buffer_pool(): Remove.

buf_flush_wait_flushed(): Require the caller to acquire buf_pool.flush_list_mutex.

logs_empty_and_mark_files_at_shutdown(): Simplify the logic.

fil_names_clear(): Fix an off-by-one error that would prevent removal from fil_system.named_spaces.

Release Notes

InnoDB shutdown was simplified.

How can this PR be tested?

rm -fr mysql-test/var
mkdir /tmp/var
ln -s /tmp/var mysql-test/var
mysql-test/mtr --repeat=10 --parallel=auto innodb.log_corruption_recovery{,,,,,}{,,,}
mysql-test/mtr --force --parallel=auto --big-test

This ensures that despite cmake -DWITH_INNODB_PMEM=ON the pwrite based log write code path will be used.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

Concurrent calls to log_checkpoint_low() were possible from multiple
threads, and they could cause redundant writes of FILE_CHECKPOINT
records. Let us simplify the logic by making the dedicated
buf_flush_page_cleaner() thread responsible for checkpoints.

log_t::write_checkpoint(lsn_t end_lsn): Add the parameter checkpoint,
which replaces log_sys.next_checkpoint_lsn.

log_sys.checkpoint_pending: Remove. Only the buf_flush_page_cleaner
thread will write checkpoints, hence there is no possibility of a
race condition.

log_checkpoint_low(), log_checkpoint(): Remove the return value,
because there cannot be any concurrent log checkpoint in progress.

buf_flush_wait(): Add special handling for log_sys.check_for_checkpoint()
as well as shutdown.

buf_flush_wait_flushed(): Assert that buf_flush_page_cleaner() is
available.

log_make_checkpoint(): Delegate all work to the page cleaner.

buf_flush_sync_for_checkpoint(): Update the systemd watchdog.
On shutdown, keep flushing until a checkpoint has been written.

buf_flush_page_cleaner(): Revise the shutdown logic so that all
changes will be written out.

buf_flush_buffer_pool(): Remove.

buf_flush_wait_flushed(): Require the caller to acquire
buf_pool.flush_list_mutex.

logs_empty_and_mark_files_at_shutdown(): Simplify the logic.

fil_names_clear(): Fix an off-by-one error that would prevent
removal from fil_system.named_spaces.
@dr-m dr-m self-assigned this Mar 6, 2026
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Fix the compilation
@dr-m dr-m marked this pull request as draft March 7, 2026 09:49
@dr-m
Copy link
Contributor Author

dr-m commented Mar 7, 2026

Apparently there are some problems with shutdown that make the tests innodb.table_flags and innodb_zip.restart fail. On i686, many --suite=mariabackup tests are failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants