diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 1e710e291f7..de6cd38187e 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -2601,24 +2601,6 @@ void recv_recover_page_func( ut_ad(end_lsn <= max_lsn); #endif /* !UNIV_HOTBACKUP */ - byte *buf = nullptr; - - if (recv->len > RECV_DATA_BLOCK_SIZE) { - /* We have to copy the record body to a separate - buffer */ - - buf = static_cast(ut_malloc_nokey(recv->len)); - - recv_data_copy_to_buf(buf, recv); - } else if (recv->data != nullptr) { - buf = ((byte *)(recv->data)) + sizeof(recv_data_t); - } else { - /* Redo record that does not have a payload, such as MLOG_UNDO_ERASE_END, - MLOG_COMP_PAGE_CREATE, MLOG_INIT_FILE_PAGE2 etc. */ - ut_ad(recv->data == nullptr); - ut_ad(recv->len == 0); - } - if (recv->type == MLOG_INIT_FILE_PAGE) { page_lsn = page_newest_lsn; @@ -2644,6 +2626,24 @@ void recv_recover_page_func( && undo::is_active(recv_addr->space) #endif /* !UNIV_HOTBACKUP */ ) { + byte *buf = nullptr; + + if (recv->len > RECV_DATA_BLOCK_SIZE) { + /* We have to copy the record body to a separate + buffer */ + + buf = static_cast(ut_malloc_nokey(recv->len)); + + recv_data_copy_to_buf(buf, recv); + } else if (recv->data != nullptr) { + buf = ((byte *)(recv->data)) + sizeof(recv_data_t); + } else { + /* Redo record that does not have a payload, such as + MLOG_UNDO_ERASE_END, MLOG_COMP_PAGE_CREATE, MLOG_INIT_FILE_PAGE2 etc. + */ + ut_ad(recv->data == nullptr); + ut_ad(recv->len == 0); + } lsn_t end_lsn; @@ -2681,16 +2681,16 @@ void recv_recover_page_func( if (page_zip) { mach_write_to_8(FIL_PAGE_LSN + page_zip->data, end_lsn); } + + if (recv->len > RECV_DATA_BLOCK_SIZE) { + ut_free(buf); + } #ifdef UNIV_HOTBACKUP ++applied_recs; } else { ++skipped_recs; #endif /* UNIV_HOTBACKUP */ } - - if (recv->len > RECV_DATA_BLOCK_SIZE) { - ut_free(buf); - } } #ifdef UNIV_ZIP_DEBUG