1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

MDEV-31234 fixup: Allow innodb_undo_log_truncate=ON after upgrade

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 e0084b9d31 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.
This commit is contained in:
Marko Mäkelä
2023-05-23 12:20:27 +03:00
committed by Sergei Golubchik
parent 48d6a5f61b
commit 3b4b512d8e

View File

@@ -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);