Skip to content

Commit

Permalink
MDEV-31234 fixup: Allow innodb_undo_log_truncate=ON after upgrade
Browse files Browse the repository at this point in the history
trx_purge_truncate_history(): Relax a condition that would prevent
undo log truncation if the undo log tablespaces were "contaminated"
by the bug that commit e0084b9 fixed.
That is, trx_purge_truncate_rseg_history() would have invoked
flst_remove() on TRX_RSEG_HISTORY but not reduced TRX_RSEG_HISTORY_SIZE.

To avoid any regression with normal operation, we implement this
fixup during slow shutdown only. The condition on the history list
being empty is necessary: without it, in the test
innodb.undo_truncate_recover there may be much fewer than the
expected 90,000 calls to row_purge() before the truncation.
That is, we would truncate the undo tablespace before actually having
processed all undo log records in it.

To truncate such "contaminated" or "bloated" undo log tablespaces
(when using innodb_undo_tablespaces=2 or more)
you can execute the following SQL:

BEGIN;INSERT mysql.innodb_table_stats VALUES('','',DEFAULT,0,0,0);ROLLBACK;
SET GLOBAL innodb_undo_log_truncate=ON, innodb_fast_shutdown=0;
SHUTDOWN;

The first line creates a dummy InnoDB transaction, to ensure that there
will be some history to be purged during shutdown and that the undo
tablespaces will be truncated.
  • Loading branch information
dr-m authored and vuvova committed Jun 3, 2023
1 parent 48d6a5f commit 3b4b512
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion storage/innobase/trx/trx0purge.cc
Expand Up @@ -626,7 +626,8 @@ static void trx_purge_truncate_history()

ut_ad(rseg->curr_size > cached);

if (rseg->curr_size > cached + 1)
if (rseg->curr_size > cached + 1 &&
(srv_fast_shutdown || srv_undo_sources || trx_sys.rseg_history_len))
goto not_free;

mutex_exit(&rseg->mutex);
Expand Down

0 comments on commit 3b4b512

Please sign in to comment.