MDEV-28601 InnoDB history list length was reverted to 32 bits
srv_do_purge(): In commit edde1f6e0d5f5a0115a5253c9b8d428af132f2d1 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).
This commit is contained in:
parent
c1d380aa88
commit
99c8aed00d
@ -1,7 +1,7 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
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
|
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
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -811,7 +811,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
TRX_RSEG_HISTORY list length (number of committed transactions to purge)
|
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. */
|
/** Mutex protecting trx_list. */
|
||||||
MY_ALIGNED(CACHE_LINE_SIZE) mutable TrxSysMutex mutex;
|
MY_ALIGNED(CACHE_LINE_SIZE) mutable TrxSysMutex mutex;
|
||||||
|
@ -4602,14 +4602,14 @@ lock_print_info_summary(
|
|||||||
fprintf(file,
|
fprintf(file,
|
||||||
"Purge done for trx's n:o < " TRX_ID_FMT
|
"Purge done for trx's n:o < " TRX_ID_FMT
|
||||||
" undo n:o < " TRX_ID_FMT " state: %s\n"
|
" 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.trx_no,
|
||||||
purge_sys.tail.undo_no,
|
purge_sys.tail.undo_no,
|
||||||
purge_sys.enabled()
|
purge_sys.enabled()
|
||||||
? (purge_sys.running() ? "running"
|
? (purge_sys.running() ? "running"
|
||||||
: purge_sys.paused() ? "stopped" : "running but idle")
|
: purge_sys.paused() ? "stopped" : "running but idle")
|
||||||
: "disabled",
|
: "disabled",
|
||||||
uint32_t{trx_sys.rseg_history_len});
|
size_t{trx_sys.rseg_history_len});
|
||||||
|
|
||||||
#ifdef PRINT_NUM_OF_LOCK_STRUCTS
|
#ifdef PRINT_NUM_OF_LOCK_STRUCTS
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
|
@ -2393,7 +2393,7 @@ static bool srv_purge_should_exit()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Slow shutdown was requested. */
|
/* 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;
|
static time_t progress_time;
|
||||||
time_t now= time(NULL);
|
time_t now= time(NULL);
|
||||||
@ -2402,7 +2402,7 @@ static bool srv_purge_should_exit()
|
|||||||
progress_time= now;
|
progress_time= now;
|
||||||
#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY
|
#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY
|
||||||
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
|
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
|
||||||
"InnoDB: to purge %u transactions",
|
"InnoDB: to purge %zu transactions",
|
||||||
history_size);
|
history_size);
|
||||||
ib::info() << "to purge " << history_size << " transactions";
|
ib::info() << "to purge " << history_size << " transactions";
|
||||||
#endif
|
#endif
|
||||||
@ -2516,17 +2516,17 @@ DECLARE_THREAD(srv_worker_thread)(
|
|||||||
/** Do the actual purge operation.
|
/** Do the actual purge operation.
|
||||||
@param[in,out] n_total_purged total number of purged pages
|
@param[in,out] n_total_purged total number of purged pages
|
||||||
@return length of history list before the last purge batch. */
|
@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
|
#ifdef UNIV_DEBUG
|
||||||
, srv_slot_t* slot /*!< purge coordinator */
|
, srv_slot_t* slot /*!< purge coordinator */
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ulint n_pages_purged;
|
ulint n_pages_purged;
|
||||||
|
|
||||||
static ulint count = 0;
|
static ulint count = 0;
|
||||||
static ulint n_use_threads = 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();
|
ulint old_activity_count = srv_get_activity_count();
|
||||||
const ulint n_threads = srv_n_purge_threads;
|
const ulint n_threads = srv_n_purge_threads;
|
||||||
|
|
||||||
@ -2606,7 +2606,7 @@ srv_purge_coordinator_suspend(
|
|||||||
/*==========================*/
|
/*==========================*/
|
||||||
srv_slot_t* slot, /*!< in/out: Purge coordinator
|
srv_slot_t* slot, /*!< in/out: Purge coordinator
|
||||||
thread slot */
|
thread slot */
|
||||||
uint32_t rseg_history_len) /*!< in: history list length
|
size_t rseg_history_len) /*!< in: history list length
|
||||||
before last purge */
|
before last purge */
|
||||||
{
|
{
|
||||||
ut_ad(!srv_read_only_mode);
|
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,
|
rw_lock_create(PFS_NOT_INSTRUMENTED, &slot->debug_sync_lock,
|
||||||
SYNC_NO_ORDER_CHECK);
|
SYNC_NO_ORDER_CHECK);
|
||||||
#endif
|
#endif
|
||||||
uint32_t rseg_history_len = trx_sys.rseg_history_len;
|
size_t rseg_history_len = trx_sys.rseg_history_len;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* If there are no records to purge or the last
|
/* If there are no records to purge or the last
|
||||||
|
Loading…
x
Reference in New Issue
Block a user