Skip to content

Commit cd92c6c

Browse files
committed
MDEV-12353 preparation: Do not write MLOG_REC_MIN_MARK
btr_set_min_rec_mark(): Write MLOG_1BYTE instead of MLOG_REC_MIN_MARK or MLOG_COMP_REC_MIN_MARK. On ROW_FORMAT=COMPRESSED pages, the minimum record flag is not stored at all. The flag is computed for the uncompressed page by page_zip_decompress(). Hence, nothing needs to be logged for ROW_FORMAT=COMPRESSED tables for this operation. To facilitate crash-upgrade and hot backup from older versions, we will retain the code to parse and apply the old log record types MLOG_REC_MIN_MARK and MLOG_COMP_REC_MIN_MARK.
1 parent 8ebd91c commit cd92c6c

File tree

5 files changed

+34
-56
lines changed

5 files changed

+34
-56
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,24 +3262,6 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
32623262
}
32633263
}
32643264

3265-
/****************************************************************//**
3266-
Writes the redo log record for setting an index record as the predefined
3267-
minimum record. */
3268-
UNIV_INLINE
3269-
void
3270-
btr_set_min_rec_mark_log(
3271-
/*=====================*/
3272-
rec_t* rec, /*!< in: record */
3273-
mlog_id_t type, /*!< in: MLOG_COMP_REC_MIN_MARK or
3274-
MLOG_REC_MIN_MARK */
3275-
mtr_t* mtr) /*!< in: mtr */
3276-
{
3277-
mlog_write_initial_log_record(rec, type, mtr);
3278-
3279-
/* Write rec offset as a 2-byte ulint */
3280-
mlog_catenate_ulint(mtr, page_offset(rec), MLOG_2BYTES);
3281-
}
3282-
32833265
/****************************************************************//**
32843266
Parses the redo log record for setting an index record as the predefined
32853267
minimum record.
@@ -3290,7 +3272,7 @@ btr_parse_set_min_rec_mark(
32903272
const byte* ptr, /*!< in: buffer */
32913273
const byte* end_ptr,/*!< in: buffer end */
32923274
ulint comp, /*!< in: nonzero=compact page format */
3293-
page_t* page, /*!< in: page or NULL */
3275+
buf_block_t* block, /*!< in: page or NULL */
32943276
mtr_t* mtr) /*!< in: mtr or NULL */
32953277
{
32963278
rec_t* rec;
@@ -3300,39 +3282,17 @@ btr_parse_set_min_rec_mark(
33003282
return(NULL);
33013283
}
33023284

3303-
if (page) {
3304-
ut_a(!page_is_comp(page) == !comp);
3285+
if (block) {
3286+
ut_a(!page_is_comp(block->frame) == !comp);
33053287

3306-
rec = page + mach_read_from_2(ptr);
3288+
rec = block->frame + mach_read_from_2(ptr);
33073289

3308-
btr_set_min_rec_mark(rec, mtr);
3290+
btr_set_min_rec_mark(rec, *block, mtr);
33093291
}
33103292

33113293
return(ptr + 2);
33123294
}
33133295

3314-
/** Sets a record as the predefined minimum record. */
3315-
void btr_set_min_rec_mark(rec_t* rec, mtr_t* mtr)
3316-
{
3317-
const bool comp = page_rec_is_comp(rec);
3318-
3319-
ut_ad(rec == page_rec_get_next_const(page_get_infimum_rec(
3320-
page_align(rec))));
3321-
ut_ad(!(rec_get_info_bits(page_rec_get_next(rec), comp)
3322-
& REC_INFO_MIN_REC_FLAG));
3323-
3324-
size_t info_bits = rec_get_info_bits(rec, comp);
3325-
if (comp) {
3326-
rec_set_info_bits_new(rec, info_bits | REC_INFO_MIN_REC_FLAG);
3327-
3328-
btr_set_min_rec_mark_log(rec, MLOG_COMP_REC_MIN_MARK, mtr);
3329-
} else {
3330-
rec_set_info_bits_old(rec, info_bits | REC_INFO_MIN_REC_FLAG);
3331-
3332-
btr_set_min_rec_mark_log(rec, MLOG_REC_MIN_MARK, mtr);
3333-
}
3334-
}
3335-
33363296
/*************************************************************//**
33373297
If page is the only on its level, this function moves its records to the
33383298
father page, thus reducing the tree height.
@@ -4258,7 +4218,7 @@ btr_discard_page(
42584218
because everything will take place within a single
42594219
mini-transaction and because writing to the redo log
42604220
is an atomic operation (performed by mtr_commit()). */
4261-
btr_set_min_rec_mark(node_ptr, mtr);
4221+
btr_set_min_rec_mark(node_ptr, *block, mtr);
42624222
}
42634223

42644224
if (dict_index_is_spatial(index)) {

storage/innobase/btr/btr0cur.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6069,7 +6069,7 @@ btr_cur_pessimistic_delete(
60696069
offsets, mtr);
60706070

60716071
if (min_mark_next_rec) {
6072-
btr_set_min_rec_mark(next_rec, mtr);
6072+
btr_set_min_rec_mark(next_rec, *block, mtr);
60736073
}
60746074

60756075
#ifdef UNIV_ZIP_DEBUG

storage/innobase/gis/gis0rtree.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ rtr_update_mbr_field(
446446
if (!ins_suc) {
447447
ut_ad(rec_info & REC_INFO_MIN_REC_FLAG);
448448

449-
btr_set_min_rec_mark(next_rec, mtr);
449+
btr_set_min_rec_mark(next_rec, *block, mtr);
450450
}
451451

452452
/* If there's more than 1 rec left in the page, delete
@@ -468,7 +468,7 @@ rtr_update_mbr_field(
468468
mark the new leftmost node pointer as
469469
the predefined minimum record */
470470
rec_t* next_rec = page_rec_get_next(cur2_rec);
471-
btr_set_min_rec_mark(next_rec, mtr);
471+
btr_set_min_rec_mark(next_rec, *block, mtr);
472472
}
473473

474474
ut_ad(del_page_no
@@ -572,7 +572,7 @@ rtr_update_mbr_field(
572572
mark the new leftmost node pointer as
573573
the predefined minimum record */
574574
rec_t* next_rec = page_rec_get_next(cur2_rec);
575-
btr_set_min_rec_mark(next_rec, mtr);
575+
btr_set_min_rec_mark(next_rec, *block, mtr);
576576
}
577577

578578
ut_ad(cur2_pno == del_page_no && cur2_rec != insert_rec);

storage/innobase/include/btr0btr.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,26 @@ btr_insert_on_non_leaf_level_func(
523523
#define btr_insert_on_non_leaf_level(f,i,l,t,m) \
524524
btr_insert_on_non_leaf_level_func(f,i,l,t,__FILE__,__LINE__,m)
525525

526-
/** Sets a record as the predefined minimum record. */
527-
void btr_set_min_rec_mark(rec_t* rec, mtr_t* mtr) MY_ATTRIBUTE((nonnull));
526+
/** Set a record as the predefined minimum record.
527+
@param[in,out] rec leftmost record on a leftmost non-leaf page
528+
@param[in,out] block buffer pool block
529+
@param[in,out] mtr mini-transaction */
530+
inline void btr_set_min_rec_mark(rec_t *rec, const buf_block_t &block,
531+
mtr_t *mtr)
532+
{
533+
ut_ad(block.frame == page_align(rec));
534+
ut_ad(!page_is_leaf(block.frame));
535+
ut_ad(!page_has_prev(block.frame));
536+
537+
rec-= page_rec_is_comp(rec) ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS;
538+
539+
if (block.page.zip.data)
540+
/* This flag is computed from other contents on a ROW_FORMAT=COMPRESSED
541+
page. We are not modifying the compressed page frame at all. */
542+
*rec|= REC_INFO_MIN_REC_FLAG;
543+
else
544+
mlog_write_ulint(rec, *rec | REC_INFO_MIN_REC_FLAG, MLOG_1BYTE, mtr);
545+
}
528546

529547
/** Seek to the parent page of a B-tree page.
530548
@param[in,out] index b-tree
@@ -581,15 +599,15 @@ btr_discard_page(
581599
Parses the redo log record for setting an index record as the predefined
582600
minimum record.
583601
@return end of log record or NULL */
602+
ATTRIBUTE_COLD MY_ATTRIBUTE((nonnull(1,2), warn_unused_result))
584603
const byte*
585604
btr_parse_set_min_rec_mark(
586605
/*=======================*/
587606
const byte* ptr, /*!< in: buffer */
588607
const byte* end_ptr,/*!< in: buffer end */
589608
ulint comp, /*!< in: nonzero=compact page format */
590-
page_t* page, /*!< in: page or NULL */
591-
mtr_t* mtr) /*!< in: mtr or NULL */
592-
MY_ATTRIBUTE((nonnull(1,2), warn_unused_result));
609+
buf_block_t* block, /*!< in: page or NULL */
610+
mtr_t* mtr); /*!< in: mtr or NULL */
593611
/***********************************************************//**
594612
Parses a redo log record of reorganizing a page.
595613
@return end of log record or NULL */

storage/innobase/log/log0recv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ recv_parse_or_apply_log_rec_body(
16301630
ut_a(type == MLOG_COMP_REC_MIN_MARK || !page_zip);
16311631
ptr = btr_parse_set_min_rec_mark(
16321632
ptr, end_ptr, type == MLOG_COMP_REC_MIN_MARK,
1633-
page, mtr);
1633+
block, mtr);
16341634
break;
16351635
case MLOG_REC_DELETE: case MLOG_COMP_REC_DELETE:
16361636
ut_ad(!page || fil_page_type_is_index(page_type));

0 commit comments

Comments
 (0)