mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 03:47:17 +02:00
MDEV-15914: Remove trx_undo_t::empty
Use the value trx_undo_t::top_undo_no == IB_ID_MAX for indicating that an undo log is empty.
This commit is contained in:
parent
c121574dff
commit
ff0000cdd2
5 changed files with 33 additions and 32 deletions
|
|
@ -370,8 +370,6 @@ struct trx_undo_t {
|
|||
top_page_no during a rollback */
|
||||
ulint size; /*!< current size in pages */
|
||||
/*-----------------------------*/
|
||||
ulint empty; /*!< TRUE if the stack of undo log
|
||||
records is currently empty */
|
||||
ulint top_page_no; /*!< page number where the latest undo
|
||||
log record was catenated; during
|
||||
rollback the page from which the latest
|
||||
|
|
@ -379,11 +377,16 @@ struct trx_undo_t {
|
|||
ulint top_offset; /*!< offset of the latest undo record,
|
||||
i.e., the topmost element in the undo
|
||||
log if we think of it as a stack */
|
||||
undo_no_t top_undo_no; /*!< undo number of the latest record */
|
||||
undo_no_t top_undo_no; /*!< undo number of the latest record
|
||||
(IB_ID_MAX if the undo log is empty) */
|
||||
buf_block_t* guess_block; /*!< guess for the buffer block where
|
||||
the top page might reside */
|
||||
ulint withdraw_clock; /*!< the withdraw clock value of the
|
||||
buffer pool when guess_block was stored */
|
||||
|
||||
/** @return whether the undo log is empty */
|
||||
bool empty() const { return top_undo_no == IB_ID_MAX; }
|
||||
|
||||
/*-----------------------------*/
|
||||
UT_LIST_NODE_T(trx_undo_t) undo_list;
|
||||
/*!< undo log objects in the rollback
|
||||
|
|
|
|||
|
|
@ -1916,11 +1916,11 @@ trx_undo_report_rename(trx_t* trx, const dict_table_t* table)
|
|||
if (ulint offset = trx_undo_page_report_rename(
|
||||
trx, table, block, &mtr)) {
|
||||
undo->withdraw_clock = buf_withdraw_clock;
|
||||
undo->empty = FALSE;
|
||||
undo->top_page_no = undo->last_page_no;
|
||||
undo->top_offset = offset;
|
||||
undo->top_undo_no = trx->undo_no++;
|
||||
undo->guess_block = block;
|
||||
ut_ad(!undo->empty());
|
||||
|
||||
err = DB_SUCCESS;
|
||||
break;
|
||||
|
|
@ -2012,7 +2012,7 @@ trx_undo_report_row_operation(
|
|||
trx_undo_t* undo = *pundo;
|
||||
|
||||
ut_ad((err == DB_SUCCESS) == (undo_block != NULL));
|
||||
if (undo_block == NULL) {
|
||||
if (UNIV_UNLIKELY(undo_block == NULL)) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
|
|
@ -2062,11 +2062,11 @@ trx_undo_report_row_operation(
|
|||
undo->withdraw_clock = buf_withdraw_clock;
|
||||
mtr_commit(&mtr);
|
||||
|
||||
undo->empty = FALSE;
|
||||
undo->top_page_no = undo_block->page.id.page_no();
|
||||
undo->top_offset = offset;
|
||||
undo->top_undo_no = trx->undo_no++;
|
||||
undo->guess_block = undo_block;
|
||||
ut_ad(!undo->empty());
|
||||
|
||||
mutex_exit(&trx->undo_mutex);
|
||||
|
||||
|
|
@ -2111,7 +2111,7 @@ trx_undo_report_row_operation(
|
|||
|
||||
DBUG_EXECUTE_IF("ib_err_ins_undo_page_add_failure",
|
||||
undo_block = NULL;);
|
||||
} while (undo_block != NULL);
|
||||
} while (UNIV_LIKELY(undo_block != NULL));
|
||||
|
||||
ib_errf(trx->mysql_thd, IB_LOG_LEVEL_ERROR,
|
||||
DB_OUT_OF_FILE_SPACE,
|
||||
|
|
|
|||
|
|
@ -946,8 +946,8 @@ trx_roll_pop_top_rec(
|
|||
true, mtr);
|
||||
|
||||
if (prev_rec == NULL) {
|
||||
|
||||
undo->empty = TRUE;
|
||||
undo->top_undo_no = IB_ID_MAX;
|
||||
ut_ad(undo->empty());
|
||||
} else {
|
||||
page_t* prev_rec_page = page_align(prev_rec);
|
||||
|
||||
|
|
@ -959,6 +959,7 @@ trx_roll_pop_top_rec(
|
|||
undo->top_page_no = page_get_page_no(prev_rec_page);
|
||||
undo->top_offset = prev_rec - prev_rec_page;
|
||||
undo->top_undo_no = trx_undo_rec_get_undo_no(prev_rec);
|
||||
ut_ad(!undo->empty());
|
||||
}
|
||||
|
||||
return(undo_page + offset);
|
||||
|
|
@ -985,19 +986,19 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap)
|
|||
trx_undo_t* temp = trx->rsegs.m_noredo.undo;
|
||||
const undo_no_t limit = trx->roll_limit;
|
||||
|
||||
ut_ad(!insert || !update || insert->empty || update->empty
|
||||
ut_ad(!insert || !update || insert->empty() || update->empty()
|
||||
|| insert->top_undo_no != update->top_undo_no);
|
||||
ut_ad(!insert || !temp || insert->empty || temp->empty
|
||||
ut_ad(!insert || !temp || insert->empty() || temp->empty()
|
||||
|| insert->top_undo_no != temp->top_undo_no);
|
||||
ut_ad(!update || !temp || update->empty || temp->empty
|
||||
ut_ad(!update || !temp || update->empty() || temp->empty()
|
||||
|| update->top_undo_no != temp->top_undo_no);
|
||||
|
||||
if (UNIV_LIKELY_NULL(insert)
|
||||
&& !insert->empty && limit <= insert->top_undo_no) {
|
||||
&& !insert->empty() && limit <= insert->top_undo_no) {
|
||||
undo = insert;
|
||||
}
|
||||
|
||||
if (update && !update->empty && update->top_undo_no >= limit) {
|
||||
if (update && !update->empty() && update->top_undo_no >= limit) {
|
||||
if (!undo) {
|
||||
undo = update;
|
||||
} else if (undo->top_undo_no < update->top_undo_no) {
|
||||
|
|
@ -1005,7 +1006,7 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap)
|
|||
}
|
||||
}
|
||||
|
||||
if (temp && !temp->empty && temp->top_undo_no >= limit) {
|
||||
if (temp && !temp->empty() && temp->top_undo_no >= limit) {
|
||||
if (!undo) {
|
||||
undo = temp;
|
||||
} else if (undo->top_undo_no < temp->top_undo_no) {
|
||||
|
|
@ -1024,7 +1025,7 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap)
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
ut_ad(!undo->empty);
|
||||
ut_ad(!undo->empty());
|
||||
ut_ad(limit <= undo->top_undo_no);
|
||||
|
||||
*roll_ptr = trx_undo_build_roll_ptr(
|
||||
|
|
|
|||
|
|
@ -571,8 +571,7 @@ trx_resurrect_table_locks(
|
|||
trx_state_eq(trx, TRX_STATE_PREPARED));
|
||||
ut_ad(undo->rseg == trx->rsegs.m_redo.rseg);
|
||||
|
||||
if (undo->empty) {
|
||||
|
||||
if (undo->empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -687,11 +686,7 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg,
|
|||
else
|
||||
trx->rsegs.m_redo.undo= undo;
|
||||
|
||||
if (!undo->empty)
|
||||
{
|
||||
trx->undo_no= undo->top_undo_no + 1;
|
||||
}
|
||||
|
||||
trx->undo_no= undo->top_undo_no + 1;
|
||||
trx->rsegs.m_redo.rseg= rseg;
|
||||
/*
|
||||
For transactions with active data will not have rseg size = 1
|
||||
|
|
@ -784,8 +779,7 @@ trx_lists_init_at_db_start()
|
|||
ut_ad(trx->rsegs.m_redo.rseg->trx_ref_count);
|
||||
|
||||
trx->rsegs.m_redo.undo = undo;
|
||||
if (!undo->empty
|
||||
&& undo->top_undo_no >= trx->undo_no) {
|
||||
if (undo->top_undo_no >= trx->undo_no) {
|
||||
if (trx_state_eq(trx,
|
||||
TRX_STATE_ACTIVE)) {
|
||||
rows_to_undo -= trx->undo_no;
|
||||
|
|
|
|||
|
|
@ -1150,13 +1150,14 @@ trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no,
|
|||
page_t* last_page = trx_undo_page_get(
|
||||
page_id_t(rseg->space->id, undo->last_page_no), &mtr);
|
||||
|
||||
const trx_undo_rec_t* rec = trx_undo_page_get_last_rec(
|
||||
last_page, page_no, offset);
|
||||
|
||||
undo->empty = !rec;
|
||||
if (rec) {
|
||||
if (const trx_undo_rec_t* rec = trx_undo_page_get_last_rec(
|
||||
last_page, page_no, offset)) {
|
||||
undo->top_offset = rec - last_page;
|
||||
undo->top_undo_no = trx_undo_rec_get_undo_no(rec);
|
||||
ut_ad(!undo->empty());
|
||||
} else {
|
||||
undo->top_undo_no = IB_ID_MAX;
|
||||
ut_ad(undo->empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1217,10 +1218,11 @@ trx_undo_mem_create(
|
|||
undo->last_page_no = page_no;
|
||||
undo->size = 1;
|
||||
|
||||
undo->empty = TRUE;
|
||||
undo->top_undo_no = IB_ID_MAX;
|
||||
undo->top_page_no = page_no;
|
||||
undo->guess_block = NULL;
|
||||
undo->withdraw_clock = 0;
|
||||
ut_ad(undo->empty());
|
||||
|
||||
return(undo);
|
||||
}
|
||||
|
|
@ -1248,7 +1250,8 @@ trx_undo_mem_init_for_reuse(
|
|||
undo->dict_operation = FALSE;
|
||||
|
||||
undo->hdr_offset = offset;
|
||||
undo->empty = TRUE;
|
||||
undo->top_undo_no = IB_ID_MAX;
|
||||
ut_ad(undo->empty());
|
||||
}
|
||||
|
||||
/** Create an undo log.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue