diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-03-29 19:42:10 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-03-29 19:42:10 +0300 |
commit | 7d7bdd4aaabb88ee13e21644d078c7dfb7cf41ac (patch) | |
tree | 24a45c2af5e38dd010b17d990de759752262c2e4 | |
parent | d875c50bf4d70e50583b2830aeec91fe6f941142 (diff) | |
download | mariadb-git-7d7bdd4aaabb88ee13e21644d078c7dfb7cf41ac.tar.gz |
MDEV-28185 InnoDB generates redundant log checkpoints
The comparison on the checkpoint age (number of log bytes
written since the previous checkpoint) is inaccurate, because
the previous FILE_CHECKPOINT record could span two 512-byte
log blocks, which will cause the LSN to increase by the size of the
log block header and footer.
We will still generate a redudant checkpoint if the previous
checkpoint wrote some FILE_MODIFY records before the FILE_CHECKPOINT
record.
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 32348c26e9f..00d96935461 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1774,9 +1774,16 @@ static bool log_checkpoint_low(lsn_t oldest_lsn, lsn_t end_lsn) ut_ad(!recv_no_log_write); ut_ad(oldest_lsn >= log_sys.last_checkpoint_lsn); + const lsn_t age= oldest_lsn - log_sys.last_checkpoint_lsn; - if (oldest_lsn > log_sys.last_checkpoint_lsn + SIZE_OF_FILE_CHECKPOINT) + + if (age > SIZE_OF_FILE_CHECKPOINT + log_sys.framing_size()) /* Some log has been written since the previous checkpoint. */; + else if (age > SIZE_OF_FILE_CHECKPOINT && + !((log_sys.log.calc_lsn_offset(oldest_lsn) ^ + log_sys.log.calc_lsn_offset(log_sys.last_checkpoint_lsn)) & + ~lsn_t{OS_FILE_LOG_BLOCK_SIZE - 1})) + /* Some log has been written to the same log block. */; else if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) /* MariaDB startup expects the redo log file to be logically empty (not even containing a FILE_CHECKPOINT record) after a clean shutdown. |