summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-03-29 19:42:10 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-03-29 19:42:10 +0300
commit7d7bdd4aaabb88ee13e21644d078c7dfb7cf41ac (patch)
tree24a45c2af5e38dd010b17d990de759752262c2e4
parentd875c50bf4d70e50583b2830aeec91fe6f941142 (diff)
downloadmariadb-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.cc9
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.