summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2023-02-06 20:29:42 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2023-02-06 20:29:42 +0200
commitacd23da4c2363511aae7d984c24cc6847aa3f19c (patch)
treeb8efaf0ec301b4b283fa45ca9a3708606e6e1332
parent461402a56432fa5cd0f6d53118ccce23081fca18 (diff)
downloadmariadb-git-acd23da4c2363511aae7d984c24cc6847aa3f19c.tar.gz
MDEV-30479 optimization: Invoke recv_sys_t::trim() earlier
recv_sys_t::parse(): Discard old page-level redo log when parsing a TRIM_PAGES record. recv_sys_t::apply(): trim() was invoked in parse() already. recv_sys_t::truncated_undo_spaces[]: Only store the size, no LSN.
-rw-r--r--storage/innobase/include/log0recv.h12
-rw-r--r--storage/innobase/log/log0recv.cc14
2 files changed, 10 insertions, 16 deletions
diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h
index e4a8f0d25a2..73d5724f612 100644
--- a/storage/innobase/include/log0recv.h
+++ b/storage/innobase/include/log0recv.h
@@ -266,15 +266,9 @@ private:
@param lsn log sequence number of the shrink operation */
inline void trim(const page_id_t page_id, lsn_t lsn);
- /** Undo tablespaces for which truncate has been logged
- (indexed by page_id_t::space() - srv_undo_space_id_start) */
- struct trunc
- {
- /** log sequence number of FILE_CREATE, or 0 if none */
- lsn_t lsn;
- /** truncated size of the tablespace, or 0 if not truncated */
- unsigned pages;
- } truncated_undo_spaces[127];
+ /** Truncated undo tablespace size for which truncate has been logged
+ (indexed by page_id_t::space() - srv_undo_space_id_start), or 0 */
+ unsigned truncated_undo_spaces[127];
public:
/** The contents of the doublewrite buffer */
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 7129de59e64..4a6527962f6 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -1949,8 +1949,10 @@ same_page:
goto record_corrupted;
static_assert(UT_ARR_SIZE(truncated_undo_spaces) ==
TRX_SYS_MAX_UNDO_SPACES, "compatibility");
- truncated_undo_spaces[space_id - srv_undo_space_id_start]=
- { recovered_lsn, page_no };
+ /* The entire undo tablespace will be reinitialized by
+ innodb_undo_log_truncate=ON. Discard old log for all pages. */
+ trim({space_id, 0}, recovered_lsn);
+ truncated_undo_spaces[space_id - srv_undo_space_id_start]= page_no;
if (undo_space_trunc)
undo_space_trunc(space_id);
#endif
@@ -2675,17 +2677,15 @@ void recv_sys_t::apply(bool last_batch)
for (auto id= srv_undo_tablespaces_open; id--;)
{
- const trunc& t= truncated_undo_spaces[id];
- if (t.lsn)
+ if (unsigned pages= truncated_undo_spaces[id])
{
- trim(page_id_t(id + srv_undo_space_id_start, 0), t.lsn);
- if (fil_space_t *space = fil_space_get(id + srv_undo_space_id_start))
+ if (fil_space_t *space= fil_space_get(id + srv_undo_space_id_start))
{
ut_ad(UT_LIST_GET_LEN(space->chain) == 1);
fil_node_t *file= UT_LIST_GET_FIRST(space->chain);
ut_ad(file->is_open());
os_file_truncate(file->name, file->handle,
- os_offset_t{t.pages} << srv_page_size_shift, true);
+ os_offset_t{pages} << srv_page_size_shift, true);
}
}
}