Skip to content

Commit acd23da

Browse files
committed
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.
1 parent 461402a commit acd23da

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

storage/innobase/include/log0recv.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,9 @@ struct recv_sys_t
266266
@param lsn log sequence number of the shrink operation */
267267
inline void trim(const page_id_t page_id, lsn_t lsn);
268268

269-
/** Undo tablespaces for which truncate has been logged
270-
(indexed by page_id_t::space() - srv_undo_space_id_start) */
271-
struct trunc
272-
{
273-
/** log sequence number of FILE_CREATE, or 0 if none */
274-
lsn_t lsn;
275-
/** truncated size of the tablespace, or 0 if not truncated */
276-
unsigned pages;
277-
} truncated_undo_spaces[127];
269+
/** Truncated undo tablespace size for which truncate has been logged
270+
(indexed by page_id_t::space() - srv_undo_space_id_start), or 0 */
271+
unsigned truncated_undo_spaces[127];
278272

279273
public:
280274
/** The contents of the doublewrite buffer */

storage/innobase/log/log0recv.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,8 +1949,10 @@ bool recv_sys_t::parse(lsn_t checkpoint_lsn, store_t *store, bool apply)
19491949
goto record_corrupted;
19501950
static_assert(UT_ARR_SIZE(truncated_undo_spaces) ==
19511951
TRX_SYS_MAX_UNDO_SPACES, "compatibility");
1952-
truncated_undo_spaces[space_id - srv_undo_space_id_start]=
1953-
{ recovered_lsn, page_no };
1952+
/* The entire undo tablespace will be reinitialized by
1953+
innodb_undo_log_truncate=ON. Discard old log for all pages. */
1954+
trim({space_id, 0}, recovered_lsn);
1955+
truncated_undo_spaces[space_id - srv_undo_space_id_start]= page_no;
19541956
if (undo_space_trunc)
19551957
undo_space_trunc(space_id);
19561958
#endif
@@ -2675,17 +2677,15 @@ void recv_sys_t::apply(bool last_batch)
26752677

26762678
for (auto id= srv_undo_tablespaces_open; id--;)
26772679
{
2678-
const trunc& t= truncated_undo_spaces[id];
2679-
if (t.lsn)
2680+
if (unsigned pages= truncated_undo_spaces[id])
26802681
{
2681-
trim(page_id_t(id + srv_undo_space_id_start, 0), t.lsn);
2682-
if (fil_space_t *space = fil_space_get(id + srv_undo_space_id_start))
2682+
if (fil_space_t *space= fil_space_get(id + srv_undo_space_id_start))
26832683
{
26842684
ut_ad(UT_LIST_GET_LEN(space->chain) == 1);
26852685
fil_node_t *file= UT_LIST_GET_FIRST(space->chain);
26862686
ut_ad(file->is_open());
26872687
os_file_truncate(file->name, file->handle,
2688-
os_offset_t{t.pages} << srv_page_size_shift, true);
2688+
os_offset_t{pages} << srv_page_size_shift, true);
26892689
}
26902690
}
26912691
}

0 commit comments

Comments
 (0)