1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Cleanup: MONITOR_EXISTING trx_undo_slots_used, trx_undo_slots_cached

Let us remove explicit updates of MONITOR_NUM_UNDO_SLOT_USED
and MONITOR_NUM_UNDO_SLOT_CACHED, and let us compute the rough values
from trx_sys.rseg_array[] on demand.
This commit is contained in:
Marko Mäkelä
2023-04-21 17:58:18 +03:00
parent 86767bcc0f
commit 204e7225dc
6 changed files with 33 additions and 22 deletions

View File

@ -164,8 +164,8 @@ trx_commits_insert_update transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NUL
trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back
trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint
trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list
trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots used trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of undo slots used
trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots cached trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of undo slots cached
trx_rseg_current_size transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current rollback segment size in pages trx_rseg_current_size transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current rollback segment size in pages
purge_del_mark_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of delete-marked rows purged purge_del_mark_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of delete-marked rows purged
purge_upd_exist_or_extern_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of purges on updates of existing records and updates on delete marked record with externally stored field purge_upd_exist_or_extern_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of purges on updates of existing records and updates on delete marked record with externally stored field

View File

@ -704,16 +704,18 @@ static monitor_info_t innodb_counter_info[] =
{"trx_rseg_history_len", "transaction", {"trx_rseg_history_len", "transaction",
"Length of the TRX_RSEG_HISTORY list", "Length of the TRX_RSEG_HISTORY list",
static_cast<monitor_type_t>( static_cast<monitor_type_t>(
MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT | MONITOR_DEFAULT_ON), MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
MONITOR_DEFAULT_START, MONITOR_RSEG_HISTORY_LEN}, MONITOR_DEFAULT_START, MONITOR_RSEG_HISTORY_LEN},
{"trx_undo_slots_used", "transaction", "Number of undo slots used", {"trx_undo_slots_used", "transaction", "Number of undo slots used",
MONITOR_NONE, static_cast<monitor_type_t>(
MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_USED}, MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_USED},
{"trx_undo_slots_cached", "transaction", {"trx_undo_slots_cached", "transaction",
"Number of undo slots cached", "Number of undo slots cached",
MONITOR_NONE, static_cast<monitor_type_t>(
MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT | MONITOR_DEFAULT_ON),
MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_CACHED}, MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_CACHED},
{"trx_rseg_current_size", "transaction", {"trx_rseg_current_size", "transaction",
@ -1383,6 +1385,24 @@ TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_size()
return size; return size;
} }
/** @return number of used undo log slots */
TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_used()
{
ulint size= 0;
for (const auto &rseg : trx_sys.rseg_array)
size+= UT_LIST_GET_LEN(rseg.undo_list);
return size;
}
/** @return number of cached undo log slots */
TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_cached()
{
ulint size= 0;
for (const auto &rseg : trx_sys.rseg_array)
size+= UT_LIST_GET_LEN(rseg.undo_cached);
return size;
}
/****************************************************************//** /****************************************************************//**
This function consolidates some existing server counters used This function consolidates some existing server counters used
by "system status variables". These existing system variables do not have by "system status variables". These existing system variables do not have
@ -1690,7 +1710,12 @@ srv_mon_process_existing_counter(
case MONITOR_RSEG_CUR_SIZE: case MONITOR_RSEG_CUR_SIZE:
value = srv_mon_get_rseg_size(); value = srv_mon_get_rseg_size();
break; break;
case MONITOR_NUM_UNDO_SLOT_USED:
value = srv_mon_get_rseg_used();
break;
case MONITOR_NUM_UNDO_SLOT_CACHED:
value = srv_mon_get_rseg_cached();
break;
case MONITOR_OVLD_N_FILE_OPENED: case MONITOR_OVLD_N_FILE_OPENED:
value = fil_system.n_open; value = fil_system.n_open;
break; break;
@ -1812,7 +1837,6 @@ srv_mon_process_existing_counter(
case MONITOR_TIMEOUT: case MONITOR_TIMEOUT:
value = lock_sys.timeouts; value = lock_sys.timeouts;
break; break;
default: default:
ut_error; ut_error;
} }

View File

@ -280,8 +280,6 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
TRX_RSEG + TRX_RSEG_UNDO_SLOTS TRX_RSEG + TRX_RSEG_UNDO_SLOTS
+ undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff); + undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff);
MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED);
uint32_t hist_size = mach_read_from_4( uint32_t hist_size = mach_read_from_4(
TRX_RSEG_HISTORY_SIZE + TRX_RSEG TRX_RSEG_HISTORY_SIZE + TRX_RSEG
+ rseg_header->page.frame); + rseg_header->page.frame);
@ -363,7 +361,6 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
if (undo->state == TRX_UNDO_CACHED) { if (undo->state == TRX_UNDO_CACHED) {
UT_LIST_ADD_FIRST(rseg->undo_cached, undo); UT_LIST_ADD_FIRST(rseg->undo_cached, undo);
MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED);
} else { } else {
ut_ad(undo->state == TRX_UNDO_TO_PURGE); ut_ad(undo->state == TRX_UNDO_TO_PURGE);
ut_free(undo); ut_free(undo);
@ -526,8 +523,6 @@ loop:
mtr.write<8,mtr_t::MAYBE_NOP>(*rseg_hdr, TRX_RSEG + TRX_RSEG_MAX_TRX_ID + mtr.write<8,mtr_t::MAYBE_NOP>(*rseg_hdr, TRX_RSEG + TRX_RSEG_MAX_TRX_ID +
rseg_hdr->page.frame, rseg_hdr->page.frame,
trx_sys.get_max_trx_id() - 1); trx_sys.get_max_trx_id() - 1);
MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED);
MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED);
goto free_segment; goto free_segment;
} }
} }

View File

@ -394,7 +394,6 @@ void trx_rseg_t::reinit(uint32_t page)
{ {
next= UT_LIST_GET_NEXT(undo_list, undo); next= UT_LIST_GET_NEXT(undo_list, undo);
UT_LIST_REMOVE(undo_cached, undo); UT_LIST_REMOVE(undo_cached, undo);
MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED);
ut_free(undo); ut_free(undo);
} }
@ -425,7 +424,6 @@ static dberr_t trx_undo_lists_init(trx_rseg_t *rseg,
if (!undo) if (!undo)
return DB_CORRUPTION; return DB_CORRUPTION;
rseg->curr_size+= undo->size; rseg->curr_size+= undo->size;
MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED);
} }
} }

View File

@ -535,8 +535,6 @@ trx_undo_seg_create(fil_space_t *space, buf_block_t *rseg_hdr, ulint *id,
+ slot_no * TRX_RSEG_SLOT_SIZE + rseg_hdr->page.frame, + slot_no * TRX_RSEG_SLOT_SIZE + rseg_hdr->page.frame,
block->page.id().page_no()); block->page.id().page_no());
MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED);
*err = DB_SUCCESS; *err = DB_SUCCESS;
return block; return block;
} }
@ -996,7 +994,6 @@ static void trx_undo_seg_free(const trx_undo_t *undo)
static_assert(FIL_NULL == 0xffffffff, "compatibility"); static_assert(FIL_NULL == 0xffffffff, "compatibility");
mtr.memset(rseg_header, TRX_RSEG + TRX_RSEG_UNDO_SLOTS + mtr.memset(rseg_header, TRX_RSEG + TRX_RSEG_UNDO_SLOTS +
undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff); undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff);
MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED);
} }
} }
@ -1155,7 +1152,6 @@ corrupted_type:
UT_LIST_ADD_LAST(rseg->undo_list, undo); UT_LIST_ADD_LAST(rseg->undo_list, undo);
} else { } else {
UT_LIST_ADD_LAST(rseg->undo_cached, undo); UT_LIST_ADD_LAST(rseg->undo_cached, undo);
MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED);
} }
mtr.commit(); mtr.commit();
@ -1333,7 +1329,6 @@ trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo,
} }
UT_LIST_REMOVE(rseg->undo_cached, undo); UT_LIST_REMOVE(rseg->undo_cached, undo);
MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED);
*pundo = undo; *pundo = undo;
@ -1546,7 +1541,6 @@ void trx_undo_commit_cleanup(trx_undo_t *undo)
if (undo->state == TRX_UNDO_CACHED) { if (undo->state == TRX_UNDO_CACHED) {
UT_LIST_ADD_FIRST(rseg->undo_cached, undo); UT_LIST_ADD_FIRST(rseg->undo_cached, undo);
MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED);
undo = nullptr; undo = nullptr;
} else { } else {
ut_ad(undo->state == TRX_UNDO_TO_PURGE); ut_ad(undo->state == TRX_UNDO_TO_PURGE);

View File

@ -146,8 +146,8 @@ trx_commits_insert_update transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NUL
trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back
trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint
trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list
trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots used trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of undo slots used
trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots cached trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of undo slots cached
trx_rseg_current_size transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current rollback segment size in pages trx_rseg_current_size transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current rollback segment size in pages
purge_del_mark_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of delete-marked rows purged purge_del_mark_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of delete-marked rows purged
purge_upd_exist_or_extern_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of purges on updates of existing records and updates on delete marked record with externally stored field purge_upd_exist_or_extern_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of purges on updates of existing records and updates on delete marked record with externally stored field