Commit 3b4b512d authored by Marko Mäkelä's avatar Marko Mäkelä Committed by Sergei Golubchik

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 e0084b9d 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.
parent 48d6a5f6
...@@ -626,7 +626,8 @@ static void trx_purge_truncate_history() ...@@ -626,7 +626,8 @@ static void trx_purge_truncate_history()
ut_ad(rseg->curr_size > cached); 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; goto not_free;
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