Skip to content

Commit

Permalink
MDEV-13542 fixup: Improve page reorganize
Browse files Browse the repository at this point in the history
btr_page_reorganize_low(): Restore mtr->set_log_mode() before returning.

innobase_instant_try(): Do not invoke rec_get_offsets() if
btr_cur_pessimistic_update() failed. The cursor position may be
invalid.
  • Loading branch information
dr-m committed Aug 1, 2022
1 parent 84d26f9 commit 34cdc00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
17 changes: 9 additions & 8 deletions storage/innobase/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,6 @@ btr_write_autoinc(dict_index_t* index, ib_uint64_t autoinc, bool reset)
static dberr_t btr_page_reorganize_low(page_cur_t *cursor, dict_index_t *index,
mtr_t *mtr)
{
const mtr_log_t log_mode= mtr->set_log_mode(MTR_LOG_NO_REDO);

buf_block_t *const block= cursor->block;

ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
Expand All @@ -1271,6 +1269,8 @@ static dberr_t btr_page_reorganize_low(page_cur_t *cursor, dict_index_t *index,
memcpy_aligned<UNIV_PAGE_SIZE_MIN>(old->page.frame, block->page.frame,
srv_page_size);

const mtr_log_t log_mode= mtr->set_log_mode(MTR_LOG_NO_REDO);

page_create(block, mtr, index->table->not_redundant());
if (index->is_spatial())
block->page.frame[FIL_PAGE_TYPE + 1]= byte(FIL_PAGE_RTREE);
Expand All @@ -1281,10 +1281,13 @@ static dberr_t btr_page_reorganize_low(page_cur_t *cursor, dict_index_t *index,
/* Copy the records from the temporary space to the recreated page;
do not copy the lock bits yet */

if (dberr_t err=
page_copy_rec_list_end_no_locks(block, old,
page_get_infimum_rec(old->page.frame),
index, mtr))
dberr_t err=
page_copy_rec_list_end_no_locks(block, old,
page_get_infimum_rec(old->page.frame),
index, mtr);
mtr->set_log_mode(log_mode);

if (UNIV_UNLIKELY(err != DB_SUCCESS))
return err;

/* Copy the PAGE_MAX_TRX_ID or PAGE_ROOT_AUTO_INC. */
Expand Down Expand Up @@ -1329,8 +1332,6 @@ static dberr_t btr_page_reorganize_low(page_cur_t *cursor, dict_index_t *index,
else if (!(cursor->rec= page_rec_get_nth(block->page.frame, pos)))
return DB_CORRUPTION;

mtr->set_log_mode(log_mode);

if (block->page.id().page_no() != index->page ||
fil_page_get_type(old->page.frame) != FIL_PAGE_TYPE_INSTANT)
ut_ad(!memcmp(old->page.frame, block->page.frame, PAGE_HEADER));
Expand Down
9 changes: 6 additions & 3 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6119,10 +6119,13 @@ static bool innobase_instant_try(
&offsets, &offsets_heap, ctx->heap,
&big_rec, update, UPD_NODE_NO_ORD_CHANGE,
thr, trx->id, &mtr);
if (err == DB_SUCCESS) {
offsets = rec_get_offsets(
btr_pcur_get_rec(&pcur), index, offsets,
index->n_core_fields, ULINT_UNDEFINED,
&offsets_heap);
}

offsets = rec_get_offsets(
btr_pcur_get_rec(&pcur), index, offsets,
index->n_core_fields, ULINT_UNDEFINED, &offsets_heap);
if (big_rec) {
if (err == DB_SUCCESS) {
err = btr_store_big_rec_extern_fields(
Expand Down

0 comments on commit 34cdc00

Please sign in to comment.