Skip to content

Commit

Permalink
MDEV-18966 Transaction recovery may be broken after upgrade to 10.3
Browse files Browse the repository at this point in the history
This bug was introduced by MDEV-12288, which made InnoDB use
a single undo log for persistent transactions, instead of
maintaining separate insert_undo and update_undo logs.

trx_undo_reuse_cached(): Initialize the TRX_UNDO_PAGE_TYPE
after reusing a cached undo log page for undo log.
Failure to do so can cause trx_undo_mem_create_at_db_start()
to misclassify new undo log records as TRX_UNDO_INSERT.
This in turn would trigger an assertion failure in
trx_roll_pop_top_rec_of_trx() due to undo==insert.
  • Loading branch information
dr-m committed Mar 19, 2019
1 parent 6893e99 commit cdb2208
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions storage/innobase/trx/trx0undo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,15 @@ trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo,
*pundo = undo;

ulint offset = trx_undo_header_create(block->frame, trx->id, mtr);
/* Reset the TRX_UNDO_PAGE_TYPE in case this page is being
repurposed after upgrading to MariaDB 10.3. */
if (ut_d(ulint type =) UNIV_UNLIKELY(
mach_read_from_2(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE
+ block->frame))) {
ut_ad(type == TRX_UNDO_INSERT || type == TRX_UNDO_UPDATE);
mlog_write_ulint(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE
+ block->frame, 0, MLOG_2BYTES, mtr);
}

trx_undo_header_add_space_for_xid(block->frame, block->frame + offset,
mtr);
Expand Down

0 comments on commit cdb2208

Please sign in to comment.