Skip to content

Commit

Permalink
MDEV-31234 fixup: Free some UNDO pages earlier
Browse files Browse the repository at this point in the history
trx_purge_truncate_rseg_history(): Add a parameter to specify if
the entire rollback segment is safe to be freed. If not, we may
still be able to invoke trx_undo_truncate_start() and free some pages.
  • Loading branch information
dr-m committed May 24, 2023
1 parent e0084b9 commit c5cf94b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions storage/innobase/trx/trx0purge.cc
Expand Up @@ -399,12 +399,14 @@ void trx_purge_free_segment(mtr_t &mtr, trx_rseg_t* rseg, fil_addr_t hdr_addr)

/** Remove unnecessary history data from a rollback segment.
@param[in,out] rseg rollback segment
@param[in] limit truncate anything before this */
@param[in] limit truncate anything before this
@param[in] all whether everything can be truncated */
static
void
trx_purge_truncate_rseg_history(
trx_rseg_t& rseg,
const purge_sys_t::iterator& limit)
const purge_sys_t::iterator& limit,
bool all)
{
fil_addr_t hdr_addr;
fil_addr_t prev_hdr_addr;
Expand Down Expand Up @@ -443,6 +445,10 @@ trx_purge_truncate_rseg_history(
goto func_exit;
}

if (!all) {
goto func_exit;
}

prev_hdr_addr = flst_get_prev_addr(block->frame + hdr_addr.boffset
+ TRX_UNDO_HISTORY_NODE);
prev_hdr_addr.boffset = static_cast<uint16_t>(prev_hdr_addr.boffset
Expand Down Expand Up @@ -539,8 +545,9 @@ static void trx_purge_truncate_history()
ut_ad(rseg->id == i);
ut_ad(rseg->is_persistent());
mutex_enter(&rseg->mutex);
if (!rseg->trx_ref_count && rseg->needs_purge <= head.trx_no)
trx_purge_truncate_rseg_history(*rseg, head);
trx_purge_truncate_rseg_history(*rseg, head,
!rseg->trx_ref_count &&
rseg->needs_purge <= head.trx_no);
mutex_exit(&rseg->mutex);
}
}
Expand Down

0 comments on commit c5cf94b

Please sign in to comment.