summaryrefslogtreecommitdiff
path: root/storage/innobase/srv/srv0srv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/srv/srv0srv.cc')
-rw-r--r--storage/innobase/srv/srv0srv.cc132
1 files changed, 34 insertions, 98 deletions
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index dd476970f26..ace166273a6 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -59,7 +59,6 @@ Created 10/8/1995 Heikki Tuuri
#include "pars0pars.h"
#include "que0que.h"
#include "row0mysql.h"
-#include "row0trunc.h"
#include "row0log.h"
#include "srv0mon.h"
#include "srv0srv.h"
@@ -77,10 +76,6 @@ Created 10/8/1995 Heikki Tuuri
#include <my_service_manager.h>
-#ifdef WITH_WSREP
-extern int wsrep_debug;
-extern int wsrep_trx_is_aborting(void *thd_ptr);
-#endif
/* The following is the maximum allowed duration of a lock wait. */
UNIV_INTERN ulong srv_fatal_semaphore_wait_threshold = DEFAULT_SRV_FATAL_SEMAPHORE_TIMEOUT;
@@ -199,8 +194,6 @@ ulong srv_page_size_shift;
/** innodb_log_write_ahead_size */
ulong srv_log_write_ahead_size;
-page_size_t univ_page_size(0, 0, false);
-
/** innodb_adaptive_flushing; try to flush dirty pages so as to avoid
IO bursts at the checkpoints. */
my_bool srv_adaptive_flushing;
@@ -498,10 +491,6 @@ UNIV_INTERN ulong srv_buf_dump_status_frequency;
mutex_enter(&srv_sys.mutex); \
} while (0)
-/** Test if the system mutex is owned. */
-#define srv_sys_mutex_own() (mutex_own(&srv_sys.mutex) \
- && !srv_read_only_mode)
-
/** Release the system mutex. */
#define srv_sys_mutex_exit() do { \
mutex_exit(&srv_sys.mutex); \
@@ -597,11 +586,12 @@ struct srv_sys_t{
sys_threads[]->event are
covered by srv_sys_t::mutex */
- ulint n_threads_active[SRV_MASTER + 1];
+ Atomic_counter<ulint>
+ n_threads_active[SRV_MASTER + 1];
/*!< number of threads active
in a thread class; protected
- by both my_atomic_addlint()
- and mutex */
+ by both std::atomic and
+ mutex */
srv_stats_t::ulint_ctr_1_t
activity_count; /*!< For tracking server
@@ -613,7 +603,7 @@ static srv_sys_t srv_sys;
/** @return whether the purge coordinator thread is active */
bool purge_sys_t::running()
{
- return my_atomic_loadlint(&srv_sys.n_threads_active[SRV_PURGE]);
+ return srv_sys.n_threads_active[SRV_PURGE];
}
/** Event to signal srv_monitor_thread. Not protected by a mutex.
@@ -812,7 +802,7 @@ srv_reserve_slot(
ut_ad(srv_slot_get_type(slot) == type);
- my_atomic_addlint(&srv_sys.n_threads_active[type], 1);
+ srv_sys.n_threads_active[type]++;
srv_sys_mutex_exit();
@@ -829,7 +819,7 @@ srv_suspend_thread_low(
srv_slot_t* slot) /*!< in/out: thread slot */
{
ut_ad(!srv_read_only_mode);
- ut_ad(srv_sys_mutex_own());
+ ut_ad(mutex_own(&srv_sys.mutex));
ut_ad(slot->in_use);
@@ -859,8 +849,7 @@ srv_suspend_thread_low(
ut_a(!slot->suspended);
slot->suspended = TRUE;
- if (lint(my_atomic_addlint(&srv_sys.n_threads_active[type], ulint(-1)))
- < 0) {
+ if (srv_sys.n_threads_active[type]-- == 0) {
ut_error;
}
@@ -917,7 +906,7 @@ srv_resume_thread(srv_slot_t* slot, int64_t sig_count = 0, bool wait = true,
ut_ad(slot->suspended);
slot->suspended = FALSE;
- my_atomic_addlint(&srv_sys.n_threads_active[slot->type], 1);
+ srv_sys.n_threads_active[slot->type]++;
srv_sys_mutex_exit();
return(timeout);
}
@@ -1328,7 +1317,7 @@ srv_printf_innodb_monitor(
fprintf(file,
"Total large memory allocated " ULINTPF "\n"
"Dictionary memory allocated " ULINTPF "\n",
- os_total_large_mem_allocated,
+ ulint{os_total_large_mem_allocated},
dict_sys_get_size());
buf_print_io(file);
@@ -1535,7 +1524,6 @@ srv_export_innodb_status(void)
export_vars.innodb_pages_created = stat.n_pages_created;
export_vars.innodb_pages_read = stat.n_pages_read;
- export_vars.innodb_page0_read = srv_stats.page0_read;
export_vars.innodb_pages_written = stat.n_pages_written;
@@ -1909,11 +1897,11 @@ void
srv_active_wake_master_thread_low()
{
ut_ad(!srv_read_only_mode);
- ut_ad(!srv_sys_mutex_own());
+ ut_ad(!mutex_own(&srv_sys.mutex));
srv_inc_activity_count();
- if (my_atomic_loadlint(&srv_sys.n_threads_active[SRV_MASTER]) == 0) {
+ if (srv_sys.n_threads_active[SRV_MASTER] == 0) {
srv_slot_t* slot;
srv_sys_mutex_enter();
@@ -1935,11 +1923,12 @@ srv_active_wake_master_thread_low()
void
srv_wake_purge_thread_if_not_active()
{
- ut_ad(!srv_sys_mutex_own());
+ ut_ad(!srv_read_only_mode);
+ ut_ad(!mutex_own(&srv_sys.mutex));
if (purge_sys.enabled() && !purge_sys.paused()
- && !my_atomic_loadlint(&srv_sys.n_threads_active[SRV_PURGE])
- && trx_sys.history_size()) {
+ && !srv_sys.n_threads_active[SRV_PURGE]
+ && trx_sys.rseg_history_len) {
srv_release_threads(SRV_PURGE, 1);
}
@@ -2007,16 +1996,12 @@ srv_master_evict_from_table_cache(
{
ulint n_tables_evicted = 0;
- rw_lock_x_lock(&dict_operation_lock);
-
- dict_mutex_enter_for_mysql();
+ dict_sys_lock();
n_tables_evicted = dict_make_room_in_cache(
innobase_get_table_cache_size(), pct_check);
- dict_mutex_exit_for_mysql();
-
- rw_lock_x_unlock(&dict_operation_lock);
+ dict_sys_unlock();
return(n_tables_evicted);
}
@@ -2432,8 +2417,7 @@ static bool srv_purge_should_exit()
return(true);
}
/* Slow shutdown was requested. */
- ulint history_size = trx_sys.history_size();
-
+ uint32_t history_size = trx_sys.rseg_history_len;
if (history_size) {
#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY
static ib_time_t progress_time;
@@ -2442,7 +2426,7 @@ static bool srv_purge_should_exit()
progress_time = time;
service_manager_extend_timeout(
INNODB_EXTEND_TIMEOUT_INTERVAL,
- "InnoDB: to purge " ULINTPF " transactions",
+ "InnoDB: to purge %u transactions",
history_size);
}
#endif
@@ -2467,7 +2451,7 @@ static bool srv_task_execute()
UT_LIST_REMOVE(srv_sys.tasks, thr);
mutex_exit(&srv_sys.tasks_mutex);
que_run_threads(thr);
- my_atomic_addlint(&purge_sys.n_completed, 1);
+ purge_sys.n_tasks.fetch_sub(1, std::memory_order_release);
return true;
}
@@ -2503,7 +2487,7 @@ DECLARE_THREAD(srv_worker_thread)(
slot = srv_reserve_slot(SRV_WORKER);
ut_a(srv_n_purge_threads > 1);
- ut_a(ulong(my_atomic_loadlint(&srv_sys.n_threads_active[SRV_WORKER]))
+ ut_a(ulong(srv_sys.n_threads_active[SRV_WORKER])
< srv_n_purge_threads);
/* We need to ensure that the worker threads exit after the
@@ -2545,14 +2529,14 @@ DECLARE_THREAD(srv_worker_thread)(
@param[in,out] n_total_purged total number of purged pages
@return length of history list before the last purge batch. */
static
-ulint
+uint32_t
srv_do_purge(ulint* n_total_purged)
{
ulint n_pages_purged;
static ulint count = 0;
static ulint n_use_threads = 0;
- static ulint rseg_history_len = 0;
+ static uint32_t rseg_history_len = 0;
ulint old_activity_count = srv_get_activity_count();
const ulint n_threads = srv_n_purge_threads;
@@ -2570,7 +2554,7 @@ srv_do_purge(ulint* n_total_purged)
}
do {
- if (trx_sys.history_size() > rseg_history_len
+ if (trx_sys.rseg_history_len > rseg_history_len
|| (srv_max_purge_lag > 0
&& rseg_history_len > srv_max_purge_lag)) {
@@ -2599,20 +2583,14 @@ srv_do_purge(ulint* n_total_purged)
ut_a(n_use_threads <= n_threads);
/* Take a snapshot of the history list before purge. */
- if (!(rseg_history_len = trx_sys.history_size())) {
+ if (!(rseg_history_len = trx_sys.rseg_history_len)) {
break;
}
- ulint undo_trunc_freq =
- purge_sys.undo_trunc.get_rseg_truncate_frequency();
-
- ulint rseg_truncate_frequency = ut_min(
- static_cast<ulint>(srv_purge_rseg_truncate_frequency),
- undo_trunc_freq);
-
n_pages_purged = trx_purge(
n_use_threads,
- (++count % rseg_truncate_frequency) == 0);
+ !(++count % srv_purge_rseg_truncate_frequency)
+ || purge_sys.truncate.current);
*n_total_purged += n_pages_purged;
} while (n_pages_purged > 0 && !purge_sys.paused()
@@ -2629,7 +2607,7 @@ srv_purge_coordinator_suspend(
/*==========================*/
srv_slot_t* slot, /*!< in/out: Purge coordinator
thread slot */
- ulint rseg_history_len) /*!< in: history list length
+ uint32_t rseg_history_len) /*!< in: history list length
before last purge */
{
ut_ad(!srv_read_only_mode);
@@ -2646,7 +2624,7 @@ srv_purge_coordinator_suspend(
/* We don't wait right away on the the non-timed wait because
we want to signal the thread that wants to suspend purge. */
const bool wait = stop
- || rseg_history_len <= trx_sys.history_size();
+ || rseg_history_len <= trx_sys.rseg_history_len;
const bool timeout = srv_resume_thread(
slot, sig_count, wait,
stop ? 0 : SRV_PURGE_MAX_TIMEOUT);
@@ -2656,12 +2634,12 @@ srv_purge_coordinator_suspend(
rw_lock_x_lock(&purge_sys.latch);
stop = srv_shutdown_state == SRV_SHUTDOWN_NONE
- && purge_sys.paused_latched();
+ && purge_sys.paused();
if (!stop) {
if (timeout
&& rseg_history_len < 5000
- && rseg_history_len == trx_sys.history_size()) {
+ && rseg_history_len == trx_sys.rseg_history_len) {
/* No new records were added since the
wait started. Simply wait for new
records. The magic number 5000 is an
@@ -2714,7 +2692,7 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
slot = srv_reserve_slot(SRV_PURGE);
- ulint rseg_history_len = trx_sys.history_size();
+ uint32_t rseg_history_len = trx_sys.rseg_history_len;
do {
/* If there are no records to purge or the last
@@ -2747,11 +2725,6 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
/* Note that we are shutting down. */
rw_lock_x_lock(&purge_sys.latch);
purge_sys.coordinator_shutdown();
-
- /* If there are any pending undo-tablespace truncate then clear
- it off as we plan to shutdown the purge thread. */
- purge_sys.undo_trunc.clear();
-
/* Ensure that the wait in purge_sys_t::stop() will terminate. */
os_event_set(purge_sys.event);
@@ -2843,9 +2816,7 @@ srv_purge_wakeup()
srv_release_threads(SRV_WORKER, n_workers);
}
- } while (!my_atomic_loadptr_explicit(reinterpret_cast<void**>
- (&srv_running),
- MY_MEMORY_ORDER_RELAXED)
+ } while (!srv_running.load(std::memory_order_relaxed)
&& (srv_sys.n_threads_active[SRV_WORKER]
|| srv_sys.n_threads_active[SRV_PURGE]));
}
@@ -2858,38 +2829,3 @@ void srv_purge_shutdown()
srv_purge_wakeup();
} while (srv_sys.sys_threads[SRV_PURGE_SLOT].in_use);
}
-
-/** Check if tablespace is being truncated.
-(Ignore system-tablespace as we don't re-create the tablespace
-and so some of the action that are suppressed by this function
-for independent tablespace are not applicable to system-tablespace).
-@param space_id space_id to check for truncate action
-@return true if being truncated, false if not being
- truncated or tablespace is system-tablespace. */
-bool
-srv_is_tablespace_truncated(ulint space_id)
-{
- if (is_system_tablespace(space_id)) {
- return(false);
- }
-
- return(truncate_t::is_tablespace_truncated(space_id)
- || undo::Truncate::is_tablespace_truncated(space_id));
-
-}
-
-/** Check if tablespace was truncated.
-@param[in] space space object to check for truncate action
-@return true if tablespace was truncated and we still have an active
-MLOG_TRUNCATE REDO log record. */
-bool
-srv_was_tablespace_truncated(const fil_space_t* space)
-{
- if (space == NULL) {
- ut_ad(0);
- return(false);
- }
-
- return (!is_system_tablespace(space->id)
- && truncate_t::was_tablespace_truncated(space->id));
-}