mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
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.
This commit is contained in:
parent
461402a564
commit
acd23da4c2
2 changed files with 10 additions and 16 deletions
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue