• Marko Mäkelä's avatar
    MDEV-31234 fixup: Allow innodb_undo_log_truncate=ON after upgrade · 9c35f9c9
    Marko Mäkelä authored
    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.
    9c35f9c9
trx0purge.cc 36.2 KB