Commit 17080cbc authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21945 Assertion w==OPT failed in trx_purge_add_undo_to_history()

By default, when redo log is being written for modifying a persistent
data page, the data page must actually be changed. If the write can
sometimes be optimized away, then the template parameter w=mtr_t::OPT
should be passed in order to silence the debug assertion failure.

InnoDB undo log pages can be reused without properly freeing or
initializing them in between. In particular, the undo log header
page field TRX_UNDO_TRX_NO could have been part of an undo log
record page, and those bytes could accidentally have the desired
value when the page is reused as an undo log header page of
another transaction.

Because the function trx_undo_set_state_at_finish() always changes
the TRX_UNDO_STATE of the page, and because recovery is only reading
TRX_UNDO_TRX_NO for pages that either have the correct TRX_UNDO_STATE
or, in trx_rseg_array_init(), are attached to the TRX_SYS page, the
garbage values in TRX_UNDO_TRX_NO do not seem to cause a problem.

This assertion failure affects debug builds only.
parent 9bd583ce
......@@ -298,7 +298,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
static_cast<uint16_t>(undo->hdr_offset
+ TRX_UNDO_HISTORY_NODE), mtr);
mtr->write<8>(*undo_page, undo_header + TRX_UNDO_TRX_NO, trx->no);
mtr->write<8,mtr_t::OPT>(*undo_page, undo_header + TRX_UNDO_TRX_NO,
trx->no);
/* This is needed for upgrading old undo log pages from
before MariaDB 10.3.1. */
if (UNIV_UNLIKELY(!mach_read_from_2(undo_header
......
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