Commit c5cf94b2 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-31234 fixup: Free some UNDO pages earlier

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.
parent e0084b9d
...@@ -399,12 +399,14 @@ void trx_purge_free_segment(mtr_t &mtr, trx_rseg_t* rseg, fil_addr_t hdr_addr) ...@@ -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. /** Remove unnecessary history data from a rollback segment.
@param[in,out] rseg 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 static
void void
trx_purge_truncate_rseg_history( trx_purge_truncate_rseg_history(
trx_rseg_t& rseg, 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 hdr_addr;
fil_addr_t prev_hdr_addr; fil_addr_t prev_hdr_addr;
...@@ -443,6 +445,10 @@ trx_purge_truncate_rseg_history( ...@@ -443,6 +445,10 @@ trx_purge_truncate_rseg_history(
goto func_exit; goto func_exit;
} }
if (!all) {
goto func_exit;
}
prev_hdr_addr = flst_get_prev_addr(block->frame + hdr_addr.boffset prev_hdr_addr = flst_get_prev_addr(block->frame + hdr_addr.boffset
+ TRX_UNDO_HISTORY_NODE); + TRX_UNDO_HISTORY_NODE);
prev_hdr_addr.boffset = static_cast<uint16_t>(prev_hdr_addr.boffset prev_hdr_addr.boffset = static_cast<uint16_t>(prev_hdr_addr.boffset
...@@ -539,8 +545,9 @@ static void trx_purge_truncate_history() ...@@ -539,8 +545,9 @@ static void trx_purge_truncate_history()
ut_ad(rseg->id == i); ut_ad(rseg->id == i);
ut_ad(rseg->is_persistent()); ut_ad(rseg->is_persistent());
mutex_enter(&rseg->mutex); 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); mutex_exit(&rseg->mutex);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment