Commit 07d39cde authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12353: Replace MLOG_UNDO_INIT

trx_undo_page_init(): Write lower-level redo log records by
invoking mtr_t::write().
parent 5bea43f5
...@@ -1806,8 +1806,8 @@ fseg_create( ...@@ -1806,8 +1806,8 @@ fseg_create(
} }
ut_ad(rw_lock_get_sx_lock_count(&block->lock) == 1); ut_ad(rw_lock_get_sx_lock_count(&block->lock) == 1);
ut_ad(!mach_read_from_2(FIL_PAGE_TYPE + block->frame));
mtr->write<2>(*block, block->frame + FIL_PAGE_TYPE, mtr->write<1>(*block, FIL_PAGE_TYPE + 1 + block->frame,
FIL_PAGE_TYPE_SYS); FIL_PAGE_TYPE_SYS);
} }
......
...@@ -257,6 +257,7 @@ trx_undo_free_at_shutdown(trx_t *trx); ...@@ -257,6 +257,7 @@ trx_undo_free_at_shutdown(trx_t *trx);
@param[in,out] mtr mini-transaction @param[in,out] mtr mini-transaction
@return end of log record @return end of log record
@retval NULL if the log record is incomplete */ @retval NULL if the log record is incomplete */
ATTRIBUTE_COLD /* only used when crash-upgrading */
byte* byte*
trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page); trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page);
/** Parse MLOG_UNDO_HDR_REUSE for crash-upgrade from MariaDB 10.2. /** Parse MLOG_UNDO_HDR_REUSE for crash-upgrade from MariaDB 10.2.
...@@ -264,6 +265,7 @@ trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page); ...@@ -264,6 +265,7 @@ trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page);
@param[in] end_ptr end of log buffer @param[in] end_ptr end of log buffer
@param[in,out] page undo page or NULL @param[in,out] page undo page or NULL
@return end of log record or NULL */ @return end of log record or NULL */
ATTRIBUTE_COLD /* only used when crash-upgrading */
byte* byte*
trx_undo_parse_page_header_reuse( trx_undo_parse_page_header_reuse(
const byte* ptr, const byte* ptr,
......
...@@ -1469,6 +1469,9 @@ recv_parse_or_apply_log_rec_body( ...@@ -1469,6 +1469,9 @@ recv_parse_or_apply_log_rec_body(
switch (type) { switch (type) {
default: default:
ut_error; ut_error;
case MLOG_1BYTE:
ut_ad(offs == FIL_PAGE_TYPE + 1);
break;
case MLOG_2BYTES: case MLOG_2BYTES:
/* Note that this can fail when the /* Note that this can fail when the
redo log been written with something redo log been written with something
......
...@@ -298,6 +298,7 @@ trx_undo_get_first_rec(const fil_space_t &space, uint32_t page_no, ...@@ -298,6 +298,7 @@ trx_undo_get_first_rec(const fil_space_t &space, uint32_t page_no,
@param[in,out] page page or NULL @param[in,out] page page or NULL
@return end of log record @return end of log record
@retval NULL if the log record is incomplete */ @retval NULL if the log record is incomplete */
ATTRIBUTE_COLD /* only used when crash-upgrading */
byte* byte*
trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page) trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page)
{ {
...@@ -331,6 +332,7 @@ trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page) ...@@ -331,6 +332,7 @@ trx_undo_parse_page_init(const byte* ptr, const byte* end_ptr, page_t* page)
@param[in] end_ptr end of log buffer @param[in] end_ptr end of log buffer
@param[in,out] page undo log page or NULL @param[in,out] page undo log page or NULL
@return end of log record or NULL */ @return end of log record or NULL */
ATTRIBUTE_COLD /* only used when crash-upgrading */
byte* byte*
trx_undo_parse_page_header_reuse( trx_undo_parse_page_header_reuse(
const byte* ptr, const byte* ptr,
...@@ -379,31 +381,21 @@ trx_undo_parse_page_header_reuse( ...@@ -379,31 +381,21 @@ trx_undo_parse_page_header_reuse(
@param[in,out] mtr mini-transaction */ @param[in,out] mtr mini-transaction */
static void trx_undo_page_init(const buf_block_t *undo_block, mtr_t *mtr) static void trx_undo_page_init(const buf_block_t *undo_block, mtr_t *mtr)
{ {
page_t* page = undo_block->frame; static_assert(FIL_PAGE_TYPE_ALLOCATED == 0, "compatibility");
mach_write_to_2(FIL_PAGE_TYPE + page, FIL_PAGE_UNDO_LOG); /* FIXME: FIL_PAGE_TYPE should be FIL_PAGE_TYPE_ALLOCATED here! */
mach_write_to_2(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE + page, 0); ut_ad(mach_read_from_2(FIL_PAGE_TYPE + undo_block->frame) < 0x100);
mach_write_to_2(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_START + page, mtr->write<1>(*undo_block, FIL_PAGE_TYPE + 1 + undo_block->frame,
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); FIL_PAGE_UNDO_LOG);
mach_write_to_2(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE + page, compile_time_assert(TRX_UNDO_PAGE_TYPE == 0);
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); compile_time_assert(TRX_UNDO_PAGE_START == 2);
compile_time_assert(TRX_UNDO_PAGE_NODE == TRX_UNDO_PAGE_FREE + 2);
mtr->set_modified();
switch (mtr->get_log_mode()) { /* MDEV-12353 FIXME: write minimal number of bytes in the new encoding */
case MTR_LOG_NONE: mtr->write<4>(*undo_block, TRX_UNDO_PAGE_HDR + undo_block->frame,
case MTR_LOG_NO_REDO: TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE);
return; mtr->write<2>(*undo_block, TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE +
case MTR_LOG_ALL: undo_block->frame,
break; TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE);
}
byte* log_ptr = mtr->get_log()->open(11 + 1);
log_ptr = mlog_write_initial_log_record_low(
MLOG_UNDO_INIT,
undo_block->page.id.space(),
undo_block->page.id.page_no(),
log_ptr, mtr);
*log_ptr++ = 0;
mlog_close(mtr, log_ptr);
} }
/** Look for a free slot for an undo log segment. /** Look for a free slot for an undo log segment.
......
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