Commit 99c8aed0 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-28601 InnoDB history list length was reverted to 32 bits

srv_do_purge(): In commit edde1f6e
when the de-facto 32-bit trx_sys_t::history_size() was replaced with
32-bit trx_sys.rseg_history_len, some more variables were changed
from ulint (size_t) to uint32_t.

The history list length is the number of committed transactions whose
undo logs are waiting to be purged. Each TRX_RSEG_HISTORY list is
storing the number of entries in a 32-bit field and each transaction
will occupy at least one undo log page. It is thinkable that the
length of each TRX_RSEG_HISTORY list may approach the maximum
representable number. The number cannot be exceeded, because the
rollback segment header is allocated from the same tablespace as
the undo log header pages it is pointing to, and because the page
numbers of a tablespace are stored in 32 bits. In any case, it is
possible that the total number of unpurged committed transactions
cannot be represented in 32 but 39 bits (corresponding to
128 rollback segments and undo tablespaces).
parent c1d380aa
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2021, MariaDB Corporation.
Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -811,7 +811,7 @@ class trx_sys_t
/**
TRX_RSEG_HISTORY list length (number of committed transactions to purge)
*/
MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter<uint32_t> rseg_history_len;
MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter<size_t> rseg_history_len;
/** Mutex protecting trx_list. */
MY_ALIGNED(CACHE_LINE_SIZE) mutable TrxSysMutex mutex;
......
......@@ -4602,14 +4602,14 @@ lock_print_info_summary(
fprintf(file,
"Purge done for trx's n:o < " TRX_ID_FMT
" undo n:o < " TRX_ID_FMT " state: %s\n"
"History list length %u\n",
"History list length %zu\n",
purge_sys.tail.trx_no,
purge_sys.tail.undo_no,
purge_sys.enabled()
? (purge_sys.running() ? "running"
: purge_sys.paused() ? "stopped" : "running but idle")
: "disabled",
uint32_t{trx_sys.rseg_history_len});
size_t{trx_sys.rseg_history_len});
#ifdef PRINT_NUM_OF_LOCK_STRUCTS
fprintf(file,
......
......@@ -2393,7 +2393,7 @@ static bool srv_purge_should_exit()
return true;
/* Slow shutdown was requested. */
if (const uint32_t history_size= trx_sys.rseg_history_len)
if (const size_t history_size= trx_sys.rseg_history_len)
{
static time_t progress_time;
time_t now= time(NULL);
......@@ -2402,7 +2402,7 @@ static bool srv_purge_should_exit()
progress_time= now;
#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
"InnoDB: to purge %u transactions",
"InnoDB: to purge %zu transactions",
history_size);
ib::info() << "to purge " << history_size << " transactions";
#endif
......@@ -2516,17 +2516,17 @@ DECLARE_THREAD(srv_worker_thread)(
/** Do the actual purge operation.
@param[in,out] n_total_purged total number of purged pages
@return length of history list before the last purge batch. */
static uint32_t srv_do_purge(ulint* n_total_purged
static size_t srv_do_purge(ulint* n_total_purged
#ifdef UNIV_DEBUG
, srv_slot_t* slot /*!< purge coordinator */
, srv_slot_t* slot /*!< purge coordinator */
#endif
)
)
{
ulint n_pages_purged;
static ulint count = 0;
static ulint n_use_threads = 0;
static uint32_t rseg_history_len = 0;
static size_t rseg_history_len = 0;
ulint old_activity_count = srv_get_activity_count();
const ulint n_threads = srv_n_purge_threads;
......@@ -2606,7 +2606,7 @@ srv_purge_coordinator_suspend(
/*==========================*/
srv_slot_t* slot, /*!< in/out: Purge coordinator
thread slot */
uint32_t rseg_history_len) /*!< in: history list length
size_t rseg_history_len) /*!< in: history list length
before last purge */
{
ut_ad(!srv_read_only_mode);
......@@ -2697,7 +2697,7 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
rw_lock_create(PFS_NOT_INSTRUMENTED, &slot->debug_sync_lock,
SYNC_NO_ORDER_CHECK);
#endif
uint32_t rseg_history_len = trx_sys.rseg_history_len;
size_t rseg_history_len = trx_sys.rseg_history_len;
do {
/* If there are no records to purge or the last
......
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