Browse Source

Make .clang-format work with clang-8

Remove keywords that are too new.
pull/1412/head
Vladislav Vaintroub 6 years ago
parent
commit
a808c18b73
  1. 6
      .clang-format
  2. 69
      storage/innobase/buf/buf0dump.cc
  3. 8
      storage/innobase/buf/buf0flu.cc
  4. 8
      storage/innobase/dict/dict0crea.cc
  5. 37
      storage/innobase/dict/dict0stats_bg.cc
  6. 10
      storage/innobase/fil/fil0fil.cc
  7. 4
      storage/innobase/fsp/fsp0sysspace.cc
  8. 37
      storage/innobase/fts/fts0opt.cc
  9. 2
      storage/innobase/handler/ha_innodb.cc
  10. 35
      storage/innobase/include/buf0dump.h
  11. 24
      storage/innobase/include/dict0stats_bg.h
  12. 3
      storage/innobase/include/lock0lock.h
  13. 45
      storage/innobase/include/srv0srv.h
  14. 2
      storage/innobase/include/srv0start.h
  15. 18
      storage/innobase/include/trx0purge.h
  16. 52
      storage/innobase/lock/lock0wait.cc
  17. 6
      storage/innobase/log/log0log.cc
  18. 280
      storage/innobase/srv/srv0srv.cc
  19. 48
      storage/innobase/srv/srv0start.cc
  20. 39
      storage/innobase/trx/trx0purge.cc

6
.clang-format

@ -7,14 +7,10 @@ AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
@ -23,7 +19,6 @@ AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
@ -93,7 +88,6 @@ ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: false
SpaceBeforeCpp11BracedList: false

69
storage/innobase/buf/buf0dump.cc

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, 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
@ -59,7 +59,7 @@ take after being waked up. */
static volatile bool buf_dump_should_start;
static volatile bool buf_load_should_start;
static ibool buf_load_abort_flag = FALSE;
static bool buf_load_abort_flag;
/* Used to temporary store dump info in order to avoid IO while holding
buffer pool mutex during dump and also to sort the contents of the dump
@ -72,30 +72,18 @@ typedef ib_uint64_t buf_dump_t;
#define BUF_DUMP_SPACE(a) ((ulint) ((a) >> 32))
#define BUF_DUMP_PAGE(a) ((ulint) ((a) & 0xFFFFFFFFUL))
/*****************************************************************//**
Wakes up the buffer pool dump/load thread and instructs it to start
a dump. This function is called by MySQL code via buffer_pool_dump_now()
and it should return immediately because the whole MySQL is frozen during
its execution. */
void
buf_dump_start()
/*============*/
/** Start the buffer pool dump/load task and instructs it to start a dump. */
void buf_dump_start()
{
buf_dump_should_start = true;
buf_do_load_dump();
buf_dump_should_start= true;
buf_do_load_dump();
}
/*****************************************************************//**
Wakes up the buffer pool dump/load thread and instructs it to start
a load. This function is called by MySQL code via buffer_pool_load_now()
and it should return immediately because the whole MySQL is frozen during
its execution. */
void
buf_load_start()
/*============*/
/** Start the buffer pool dump/load task and instructs it to start a load. */
void buf_load_start()
{
buf_load_should_start = true;
buf_do_load_dump();
buf_load_should_start= true;
buf_do_load_dump();
}
/*****************************************************************//**
@ -536,7 +524,7 @@ buf_load()
int fscanf_ret;
/* Ignore any leftovers from before */
buf_load_abort_flag = FALSE;
buf_load_abort_flag = false;
buf_dump_generate_path(full_filename, sizeof(full_filename));
@ -727,7 +715,7 @@ buf_load()
if (space != NULL) {
space->release();
}
buf_load_abort_flag = FALSE;
buf_load_abort_flag = false;
ut_free(dump);
buf_load_status(
STATUS_INFO,
@ -750,7 +738,7 @@ buf_load()
#ifdef UNIV_DEBUG
if ((i+1) >= srv_buf_pool_load_pages_abort) {
buf_load_abort_flag = 1;
buf_load_abort_flag = true;
}
#endif
}
@ -789,15 +777,10 @@ buf_load()
#endif /* HAVE_PSI_STAGE_INTERFACE */
}
/*****************************************************************//**
Aborts a currently running buffer pool load. This function is called by
MySQL code via buffer_pool_load_abort() and it should return immediately
because the whole MySQL is frozen during its execution. */
void
buf_load_abort()
/*============*/
/** Abort a currently running buffer pool load. */
void buf_load_abort()
{
buf_load_abort_flag = TRUE;
buf_load_abort_flag= true;
}
/*****************************************************************//**
@ -850,30 +833,28 @@ static void buf_dump_load_func(void *)
}
/* Execute tak with max.concurrency */
tpool::task_group tpool_group(1);
/* Execute task with max.concurrency */
static tpool::task_group tpool_group(1);
static tpool::waitable_task buf_dump_load_task(buf_dump_load_func, &tpool_group);
static bool load_dump_enabled;
/** Start async buffer pool load, if srv_buffer_pool_load_at_startup was set.*/
void buf_load_at_startup()
{
load_dump_enabled = true;
if (srv_buffer_pool_load_at_startup) {
buf_do_load_dump();
}
load_dump_enabled= true;
if (srv_buffer_pool_load_at_startup)
buf_do_load_dump();
}
static void buf_do_load_dump()
{
if (!load_dump_enabled || buf_dump_load_task.is_running())
return;
srv_thread_pool->submit_task(&buf_dump_load_task);
if (load_dump_enabled && !buf_dump_load_task.is_running())
srv_thread_pool->submit_task(&buf_dump_load_task);
}
/** Wait for currently running load/dumps to finish*/
void buf_load_dump_end()
{
ut_ad(SHUTTING_DOWN());
buf_dump_load_task.wait();
ut_ad(SHUTTING_DOWN());
buf_dump_load_task.wait();
}

8
storage/innobase/buf/buf0flu.cc

@ -3274,8 +3274,8 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*)
/* At this point all threads including the master and the purge
thread must have been suspended. */
ut_a(!srv_any_background_activity());
ut_a(srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE);
ut_ad(!srv_any_background_activity());
ut_ad(srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE);
/* We can now make a final sweep on flushing the buffer pool
and exit after we have cleaned the whole buffer pool.
@ -3306,8 +3306,8 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*)
} while (!success || n_flushed > 0);
/* Some sanity checks */
ut_a(!srv_any_background_activity());
ut_a(srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE);
ut_ad(!srv_any_background_activity());
ut_ad(srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE);
for (ulint i = 0; i < srv_buf_pool_instances; i++) {
buf_pool_t* buf_pool = buf_pool_from_array(i);

8
storage/innobase/dict/dict0crea.cc

@ -1355,7 +1355,7 @@ dict_check_if_system_table_exists(
dict_table_t* sys_table;
dberr_t error = DB_SUCCESS;
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
mutex_enter(&dict_sys.mutex);
@ -1395,7 +1395,7 @@ dict_create_or_check_foreign_constraint_tables(void)
dberr_t sys_foreign_err;
dberr_t sys_foreign_cols_err;
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
/* Note: The master thread has not been started at this point. */
@ -1537,7 +1537,7 @@ dict_create_or_check_sys_virtual()
my_bool srv_file_per_table_backup;
dberr_t err;
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
/* Note: The master thread has not been started at this point. */
err = dict_check_if_system_table_exists(
@ -2064,7 +2064,7 @@ dict_create_or_check_sys_tablespace(void)
dberr_t sys_tablespaces_err;
dberr_t sys_datafiles_err;
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
/* Note: The master thread has not been started at this point. */

37
storage/innobase/dict/dict0stats_bg.cc

@ -284,11 +284,9 @@ dict_stats_wait_bg_to_stop_using_table(
/*****************************************************************//**
Initialize global variables needed for the operation of dict_stats_thread()
Must be called before dict_stats_thread() is started. */
void
dict_stats_init()
void dict_stats_init()
{
ut_a(!srv_read_only_mode);
ut_ad(!srv_read_only_mode);
/* The recalc_pool_mutex is acquired from:
1) the background stats gathering thread before any other latch
@ -313,15 +311,13 @@ dict_stats_init()
/*****************************************************************//**
Free resources allocated by dict_stats_init(), must be called
after dict_stats task has exited. */
void
dict_stats_deinit()
/*======================*/
void dict_stats_deinit()
{
if (!stats_initialised) {
return;
}
ut_a(!srv_read_only_mode);
ut_ad(!srv_read_only_mode);
stats_initialised = false;
dict_stats_recalc_pool_deinit();
@ -427,7 +423,7 @@ void dict_stats_disabled_debug_update(THD*, st_mysql_sys_var*, void*,
#endif /* UNIV_DEBUG */
static tpool::timer* dict_stats_timer;
std::mutex dict_stats_mutex;
static std::mutex dict_stats_mutex;
static void dict_stats_func(void*)
{
@ -438,31 +434,28 @@ static void dict_stats_func(void*)
void dict_stats_start()
{
std::lock_guard<std::mutex> lk(dict_stats_mutex);
if (dict_stats_timer) {
return;
}
dict_stats_timer = srv_thread_pool->create_timer(dict_stats_func);
std::lock_guard<std::mutex> lk(dict_stats_mutex);
if (!dict_stats_timer)
dict_stats_timer= srv_thread_pool->create_timer(dict_stats_func);
}
static void dict_stats_schedule(int ms)
{
std::lock_guard<std::mutex> lk(dict_stats_mutex);
if(dict_stats_timer) {
dict_stats_timer->set_time(ms,0);
}
std::lock_guard<std::mutex> lk(dict_stats_mutex);
if (dict_stats_timer)
dict_stats_timer->set_time(ms,0);
}
void dict_stats_schedule_now()
{
dict_stats_schedule(0);
dict_stats_schedule(0);
}
/** Shut down the dict_stats_thread. */
void dict_stats_shutdown()
{
std::lock_guard<std::mutex> lk(dict_stats_mutex);
delete dict_stats_timer;
dict_stats_timer = 0;
std::lock_guard<std::mutex> lk(dict_stats_mutex);
delete dict_stats_timer;
dict_stats_timer= 0;
}

10
storage/innobase/fil/fil0fil.cc

@ -4331,13 +4331,11 @@ fil_io(
#include <tpool.h>
/**********************************************************************/
/* Callback for AIO completion */
void
fil_aio_callback(const tpool::aiocb *cb)
/** Callback for AIO completion */
void fil_aio_callback(const tpool::aiocb *cb)
{
os_aio_userdata_t *data=(os_aio_userdata_t *)cb->m_userdata;
fil_node_t* node= data->node;
IORequest type = data->type;
void* message = data->message;
ut_ad(fil_validate_skip());
@ -4351,7 +4349,7 @@ fil_aio_callback(const tpool::aiocb *cb)
mutex_enter(&fil_system.mutex);
fil_node_complete_io(node, type);
fil_node_complete_io(node, data->type);
ut_ad(node->space->purpose != FIL_TYPE_LOG);
const ulint space_id= node->space->id;
bool dblwr = node->space->use_doublewrite();
@ -4384,7 +4382,7 @@ fil_aio_callback(const tpool::aiocb *cb)
return;
}
ut_ad(type.is_read());
ut_ad(data->type.is_read());
if (recv_recovery_is_on() && !srv_force_recovery) {
recv_sys.found_corrupt_fs = true;
}

4
storage/innobase/fsp/fsp0sysspace.cc

@ -390,7 +390,7 @@ dberr_t
SysTablespace::set_size(
Datafile& file)
{
ut_a(!srv_read_only_mode || m_ignore_read_only);
ut_ad(!srv_read_only_mode || m_ignore_read_only);
/* We created the data file and now write it full of zeros */
ib::info() << "Setting file '" << file.filepath() << "' size to "
@ -425,7 +425,7 @@ SysTablespace::create_file(
dberr_t err = DB_SUCCESS;
ut_a(!file.m_exists);
ut_a(!srv_read_only_mode || m_ignore_read_only);
ut_ad(!srv_read_only_mode || m_ignore_read_only);
switch (file.m_type) {
case SRV_NEW_RAW:

37
storage/innobase/fts/fts0opt.cc

@ -2542,20 +2542,19 @@ fts_optimize_create_msg(
}
/** Add message to wqueue, signal thread pool*/
void add_msg(fts_msg_t *msg, bool wq_locked = false)
static void add_msg(fts_msg_t *msg, bool wq_locked= false)
{
ut_a(fts_optimize_wq);
ib_wqueue_add(fts_optimize_wq,msg, msg->heap,wq_locked);
srv_thread_pool->submit_task(&task);
ib_wqueue_add(fts_optimize_wq, msg, msg->heap, wq_locked);
srv_thread_pool->submit_task(&task);
}
/**
Called by "idle" timer. Submits optimize task, which
will only recalculate is_sync_needed, in case the queue is empty.
*/
static void timer_callback(void *)
static void timer_callback(void*)
{
srv_thread_pool->submit_task(&task);
srv_thread_pool->submit_task(&task);
}
/** Add the table to add to the OPTIMIZER's list.
@ -2581,7 +2580,7 @@ void fts_optimize_add_table(dict_table_t* table)
mutex_enter(&fts_optimize_wq->mutex);
add_msg(msg,true);
add_msg(msg, true);
table->fts->in_queue = true;
@ -2808,16 +2807,12 @@ static void fts_optimize_sync_table(dict_table_t* table)
/**********************************************************************//**
Optimize all FTS tables.
@return Dummy return */
static
void fts_optimize_callback(
/*================*/
void* arg) /*!< in: work queue*/
static void fts_optimize_callback(void *)
{
static ulint current = 0;
static ibool done = FALSE;
static ulint n_tables = ib_vector_size(fts_slots);
static ulint n_optimize = 0;
ib_wqueue_t* wq = fts_optimize_wq;
ut_ad(!srv_read_only_mode);
@ -2832,7 +2827,7 @@ void fts_optimize_callback(
to optimize then optimize the tables. */
if (!done
&& ib_wqueue_is_empty(wq)
&& ib_wqueue_is_empty(fts_optimize_wq)
&& n_tables > 0
&& n_optimize > 0) {
fts_slot_t* slot = static_cast<fts_slot_t*>(
@ -2850,9 +2845,10 @@ void fts_optimize_callback(
current = 0;
}
} else if (n_optimize == 0 || !ib_wqueue_is_empty(wq)) {
fts_msg_t* msg;
msg = static_cast<fts_msg_t*>(ib_wqueue_nowait(wq));
} else if (n_optimize == 0
|| !ib_wqueue_is_empty(fts_optimize_wq)) {
fts_msg_t* msg = static_cast<fts_msg_t*>
(ib_wqueue_nowait(fts_optimize_wq));
/* Timeout ? */
if (msg == NULL) {
if (fts_is_sync_needed()) {
@ -2998,18 +2994,17 @@ fts_optimize_shutdown()
/* We tell the OPTIMIZE thread to switch to state done, we
can't delete the work queue here because the add thread needs
deregister the FTS tables. */
delete timer;
timer = NULL;
task_group.cancel_pending(&task);
delete timer;
timer = NULL;
task_group.cancel_pending(&task);
msg = fts_optimize_create_msg(FTS_MSG_STOP, NULL);
add_msg(msg, false);
add_msg(msg);
os_event_wait(fts_opt_shutdown_event);
os_event_destroy(fts_opt_shutdown_event);
ib_wqueue_free(fts_optimize_wq);
fts_optimize_wq = NULL;
}

2
storage/innobase/handler/ha_innodb.cc

@ -57,7 +57,6 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "field.h"
#include "srv0srv.h"
// MYSQL_PLUGIN_IMPORT extern my_bool lower_case_file_system;
// MYSQL_PLUGIN_IMPORT extern char mysql_unpacked_real_data_home[];
@ -104,7 +103,6 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "row0upd.h"
#include "fil0crypt.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "srv0start.h"
#ifdef UNIV_DEBUG
#include "trx0purge.h"

35
storage/innobase/include/buf0dump.h

@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 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
@ -26,33 +27,13 @@ Created April 08, 2011 Vasil Dimov
#ifndef buf0dump_h
#define buf0dump_h
#include "univ.i"
/*****************************************************************//**
Starts the buffer pool dump/load task dump/load thread and instructs it to start
a dump. This function is called by MySQL code via buffer_pool_dump_now()
and it should return immediately because the whole MySQL is frozen during
its execution. */
void
buf_dump_start();
/*============*/
/*****************************************************************//**
Starts the buffer pool dump/load task (if not started) and instructs it to start
a load. This function is called by MySQL code via buffer_pool_load_now()
and it should return immediately because the whole MySQL is frozen during
its execution. */
void
buf_load_start();
/*============*/
/*****************************************************************//**
Aborts a currently running buffer pool load. This function is called by
MySQL code via buffer_pool_load_abort() and it should return immediately
because the whole MySQL is frozen during its execution. */
void
buf_load_abort();
/*============*/
/** Start the buffer pool dump/load task and instructs it to start a dump. */
void buf_dump_start();
/** Start the buffer pool dump/load task and instructs it to start a load. */
void buf_load_start();
/** Abort a currently running buffer pool load. */
void buf_load_abort();
/** Start async buffer pool load, if srv_buffer_pool_load_at_startup was set.*/
void buf_load_at_startup();

24
storage/innobase/include/dict0stats_bg.h

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, 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
@ -97,16 +97,12 @@ dict_stats_wait_bg_to_stop_using_table(
/*****************************************************************//**
Initialize global variables needed for the operation of dict_stats_thread().
Must be called before dict_stats task is started. */
void
dict_stats_init();
/*====================*/
void dict_stats_init();
/*****************************************************************//**
Free resources allocated by dict_stats_thread_init(), must be called
after dict_stats task has exited. */
void
dict_stats_deinit();
/*======================*/
void dict_stats_deinit();
#ifdef UNIV_DEBUG
/** Disables dict stats thread. It's used by:
@ -116,17 +112,13 @@ void dict_stats_disabled_debug_update(THD*, st_mysql_sys_var*, void*,
const void* save);
#endif /* UNIV_DEBUG */
/** Start the dict stats timer */
void
dict_stats_start();
/** Start the dict stats timer. */
void dict_stats_start();
/** Shut down the dict_stats timer. */
void
dict_stats_shutdown();
void dict_stats_shutdown();
/** reschedule dict stats timer to run now. */
void
dict_stats_schedule_now();
/** Reschedule dict stats timer to run now. */
void dict_stats_schedule_now();
#endif /* dict0stats_bg_h */

3
storage/innobase/include/lock0lock.h

@ -646,8 +646,7 @@ lock_table_has_locks(
held on records in this table or on the
table itself */
/*********************************************************************//**
A task which wakes up threads whose lock wait may have lasted too long. */
/** A task which wakes up threads whose lock wait may have lasted too long */
void lock_wait_timeout_task(void*);
/********************************************************************//**

45
storage/innobase/include/srv0srv.h

@ -439,10 +439,6 @@ extern uint srv_fast_shutdown; /*!< If this is 1, do not do a
InnoDB (but lose no committed
transactions). */
/** Signal to shut down InnoDB (NULL if shutdown was signaled, or if
running in innodb_read_only mode, srv_read_only_mode) */
extern std::atomic<st_my_thread_var *> srv_running;
extern ibool srv_innodb_status;
extern unsigned long long srv_stats_transient_sample_pages;
@ -785,13 +781,10 @@ srv_que_task_enqueue_low(
/*=====================*/
que_thr_t* thr); /*!< in: query thread */
/**********************************************************************//**
Check whether purge or master is active.
@return false if all are are suspended or have exited, true
if any are still active. */
#ifdef UNIV_DEBUG
/** @return whether purge or master task is active */
bool srv_any_background_activity();
/*============================*/
#endif
extern "C" {
@ -801,7 +794,7 @@ void srv_monitor_task(void*);
/** The periodic master task controlling the server. */
void srv_master_callback(void *);
void srv_master_callback(void*);
/**
@ -819,17 +812,13 @@ void srv_error_monitor_task(void*);
} /* extern "C" */
/**********************************************************************//**
Get count of tasks in the queue.
@return number of tasks in queue */
ulint
srv_get_task_queue_length(void);
/*===========================*/
#ifdef UNIV_DEBUG
/** @return number of tasks in queue */
ulint srv_get_task_queue_length();
#endif
/** Wakeup the purge threads. */
void
srv_purge_wakeup();
void srv_purge_wakeup();
/** Shut down the purge threads. */
void srv_purge_shutdown();
@ -837,9 +826,6 @@ void srv_purge_shutdown();
/** Init purge tasks*/
void srv_init_purge_tasks(uint n_max);
/** Shut down purge tasks*/
void srv_shutdown_purge_tasks();
#ifdef UNIV_DEBUG
/** Disables master thread. It's used by:
SET GLOBAL innodb_master_thread_disabled_debug = 1 (0).
@ -1034,18 +1020,15 @@ extern std::unique_ptr<tpool::timer> srv_master_timer;
extern std::unique_ptr<tpool::timer> srv_error_monitor_timer;
extern std::unique_ptr<tpool::timer> srv_monitor_timer;
#define SRV_MONITOR_TIMER_PERIOD 5000
static inline void srv_monitor_timer_schedule_now()
{
srv_monitor_timer->set_time(0, SRV_MONITOR_TIMER_PERIOD);
srv_monitor_timer->set_time(0, 5000);
}
static inline void srv_start_periodic_timer(
std::unique_ptr<tpool::timer>& timer,
void (*func)(void*),
int period)
static inline void srv_start_periodic_timer(std::unique_ptr<tpool::timer>& t,
void (*func)(void*), int period)
{
timer.reset(srv_thread_pool->create_timer(func));
timer->set_time(0, period);
t.reset(srv_thread_pool->create_timer(func));
t->set_time(0, period);
}
void srv_thread_pool_init();

2
storage/innobase/include/srv0start.h

@ -50,7 +50,7 @@ dberr_t srv_start(bool create_new_db);
/**
Shutdown purge to make sure that there is no possibility that we call any
plugin code (e.g audit) inside virtual column computation.
plugin code (e.g., audit) inside virtual column computation.
*/
void innodb_preshutdown();

18
storage/innobase/include/trx0purge.h

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, 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
@ -53,16 +53,12 @@ Remove the undo log segment from the rseg slot if it is too big for reuse.
@param[in,out] mtr mini-transaction */
void
trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr);
/*******************************************************************//**
This function runs a purge batch.
/**
Run a purge batch.
@param n_tasks number of purge tasks to submit to the queue
@param truncate whether to truncate the history at the end of the batch
@return number of undo log pages handled in the batch */
ulint
trx_purge(
/*======*/
ulint n_purge_threads, /*!< in: number of purge tasks to
submit to task queue. */
bool truncate /*!< in: truncate history if true */
);
ulint trx_purge(ulint n_tasks, bool truncate);
/** Rollback segements from a given transaction with trx-no
scheduled for purge. */
@ -224,7 +220,7 @@ public:
uninitialised. Real initialisation happens in create().
*/
purge_sys_t():m_initialized(false),m_enabled(false) {}
purge_sys_t(): m_initialized(false), m_enabled(false) {}
/** Create the instance */

52
storage/innobase/lock/lock0wait.cc

@ -501,33 +501,31 @@ lock_wait_check_and_cancel(
}
}
/** Task that is periodically runs in the thread pool*/
/** A task which wakes up threads whose lock wait may have lasted too long */
void lock_wait_timeout_task(void*)
{
lock_wait_mutex_enter();
/* Check all slots for user threads that are waiting
on locks, and if they have exceeded the time limit. */
bool any_slot_in_use = false;
for (srv_slot_t* slot = lock_sys.waiting_threads;
slot < lock_sys.last_slot;
++slot) {
/* We are doing a read without the lock mutex
and/or the trx mutex. This is OK because a slot
can't be freed or reserved without the lock wait
mutex. */
if (slot->in_use) {
any_slot_in_use = true;
lock_wait_check_and_cancel(slot);
}
}
if (any_slot_in_use) {
lock_sys.timeout_timer->set_time(1000, 0);
} else {
lock_sys.timeout_timer_active = false;
}
lock_wait_mutex_exit();
lock_wait_mutex_enter();
/* Check all slots for user threads that are waiting
on locks, and if they have exceeded the time limit. */
bool any_slot_in_use= false;
for (srv_slot_t *slot= lock_sys.waiting_threads;
slot < lock_sys.last_slot; ++slot)
{
/* We are doing a read without the lock mutex and/or the trx
mutex. This is OK because a slot can't be freed or reserved
without the lock wait mutex. */
if (slot->in_use)
{
any_slot_in_use= true;
lock_wait_check_and_cancel(slot);
}
}
if (any_slot_in_use)
lock_sys.timeout_timer->set_time(1000, 0);
else
lock_sys.timeout_timer_active= false;
lock_wait_mutex_exit();
}

6
storage/innobase/log/log0log.cc

@ -1605,7 +1605,7 @@ wait_suspend_loop:
/* Check that the background threads are suspended */
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
if (srv_n_fil_crypt_threads_started) {
os_event_set(fil_crypt_threads_event);
thread_name = "fil_crypt_thread";
@ -1728,7 +1728,7 @@ wait_suspend_loop:
srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
/* Make some checks that the server really is quiet */
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
"Free innodb buffer pool");
@ -1756,7 +1756,7 @@ wait_suspend_loop:
fil_close_all_files();
/* Make some checks that the server really is quiet */
ut_a(!srv_any_background_activity());
ut_ad(!srv_any_background_activity());
ut_a(lsn == log_sys.lsn
|| srv_force_recovery == SRV_FORCE_NO_LOG_REDO);

280
storage/innobase/srv/srv0srv.cc

@ -586,23 +586,17 @@ static srv_sys_t srv_sys;
*/
struct purge_coordinator_state
{
/* Snapshot of the last history length before the purge call.*/
uint32 m_history_length;
Atomic_counter<int> m_running;
purge_coordinator_state() :
m_history_length(), m_running(0)
{}
/** Snapshot of the last history length before the purge call.*/
uint32 m_history_length;
Atomic_counter<int> m_running;
purge_coordinator_state() : m_history_length(), m_running(0) {}
};
static purge_coordinator_state purge_state;
extern tpool::waitable_task purge_coordinator_task;
/** @return whether the purge coordinator thread is active */
bool purge_sys_t::running()
{
return purge_coordinator_task.is_running();
}
bool purge_sys_t::running() { return purge_coordinator_task.is_running(); }
/** threadpool timer for srv_error_monitor_task(). */
std::unique_ptr<tpool::timer> srv_error_monitor_timer;
@ -726,30 +720,29 @@ static void thread_pool_thread_end()
void srv_thread_pool_init()
{
DBUG_ASSERT(!srv_thread_pool);
DBUG_ASSERT(!srv_thread_pool);
#if defined (_WIN32)
srv_thread_pool = tpool::create_thread_pool_win();
srv_thread_pool= tpool::create_thread_pool_win();
#else
srv_thread_pool = tpool::create_thread_pool_generic();
srv_thread_pool= tpool::create_thread_pool_generic();
#endif
srv_thread_pool->set_thread_callbacks(thread_pool_thread_init, thread_pool_thread_end);
srv_thread_pool->set_thread_callbacks(thread_pool_thread_init,
thread_pool_thread_end);
}
void srv_thread_pool_end()
{
ut_a(!srv_master_timer);
delete srv_thread_pool;
srv_thread_pool = nullptr;
ut_ad(!srv_master_timer);
delete srv_thread_pool;
srv_thread_pool= nullptr;
}
static bool need_srv_free;
/** Initialize the server. */
static
void
srv_init()
static void srv_init()
{
mutex_create(LATCH_ID_SRV_INNODB_MONITOR, &srv_innodb_monitor_mutex);
srv_thread_pool_init();
@ -1407,16 +1400,14 @@ srv_export_innodb_status(void)
struct srv_monitor_state_t
{
time_t last_monitor_time;
ulint mutex_skipped;
bool last_srv_print_monitor;
srv_monitor_state_t()
{
srv_last_monitor_time = time(NULL);
last_monitor_time = srv_last_monitor_time;
mutex_skipped = 0;
last_srv_print_monitor = false;
}
time_t last_monitor_time;
ulint mutex_skipped;
bool last_srv_print_monitor;
srv_monitor_state_t() : mutex_skipped(0), last_srv_print_monitor(false)
{
srv_last_monitor_time = time(NULL);
last_monitor_time= srv_last_monitor_time;
}
};
static srv_monitor_state_t monitor_state;
@ -1558,18 +1549,18 @@ srv_inc_activity_count(void)
srv_sys.activity_count.inc();
}
/**
Check whether purge or master are still active.
@return true if something is active, false if not.
*/
#ifdef UNIV_DEBUG
/** @return whether purge or master task is active */
bool srv_any_background_activity()
{
if (purge_sys.enabled() || srv_master_timer.get()) {
ut_ad(!srv_read_only_mode);
return true;
}
return false;
if (purge_sys.enabled() || srv_master_timer.get())
{
ut_ad(!srv_read_only_mode);
return true;
}
return false;
}
#endif /* UNIV_DEBUG */
/** Wake up the InnoDB master thread if it was suspended (not sleeping). */
void
@ -1582,17 +1573,19 @@ srv_active_wake_master_thread_low()
}
void purge_worker_callback(void*);
void purge_coordinator_callback(void*);
void purge_coordinator_timer_callback(void*);
static void purge_worker_callback(void*);
static void purge_coordinator_callback(void*);
static void purge_coordinator_timer_callback(void*);
tpool::task_group purge_task_group;
tpool::waitable_task purge_worker_task(purge_worker_callback, nullptr, &purge_task_group);
static tpool::task_group purge_task_group;
tpool::waitable_task purge_worker_task(purge_worker_callback, nullptr,
&purge_task_group);
static tpool::task_group purge_coordinator_task_group(1);
tpool::waitable_task purge_coordinator_task(purge_coordinator_callback,
nullptr,
&purge_coordinator_task_group);
tpool::task_group purge_coordinator_task_group(1);
tpool::waitable_task purge_coordinator_task(purge_coordinator_callback, nullptr, &purge_coordinator_task_group);
tpool::timer* purge_coordinator_timer;
static tpool::timer *purge_coordinator_timer;
/** Wake up the purge threads if there is work to do. */
void
@ -1965,10 +1958,7 @@ srv_shutdown(bool ibuf_merge)
} while (n_bytes_merged || n_tables_to_drop);
}
/*********************************************************************//**
The periodic master controlling the server.
@return a dummy parameter */
/** The periodic master task controlling the server. */
void srv_master_callback(void*)
{
static ulint old_activity_count;
@ -2117,17 +2107,16 @@ static uint32_t srv_do_purge(ulint* n_total_purged)
}
std::queue<THD*> purge_thds;
std::mutex purge_thd_mutex;
static std::queue<THD*> purge_thds;
static std::mutex purge_thd_mutex;
void purge_create_background_thds(int n)
static void purge_create_background_thds(int n)
{
THD* thd = current_thd;
std::unique_lock<std::mutex> lk(purge_thd_mutex);
for (int i = 0; i < n; i++) {
purge_thds.push(innobase_create_background_thd("InnoDB purge worker"));
}
set_current_thd(thd);
THD *thd= current_thd;
std::unique_lock<std::mutex> lk(purge_thd_mutex);
while (n--)
purge_thds.push(innobase_create_background_thd("InnoDB purge worker"));
set_current_thd(thd);
}
extern void* thd_attach_thd(THD*);
@ -2162,103 +2151,98 @@ void release_thd(THD *thd, void *ctx)
Called by timer when purge coordinator decides
to delay processing of purge records.
*/
void purge_coordinator_timer_callback(void *)
static void purge_coordinator_timer_callback(void *)
{
if (!purge_sys.enabled() || purge_sys.paused() ||
purge_state.m_running || !trx_sys.rseg_history_len) {
return;
}
if (purge_state.m_history_length < 5000 &&
purge_state.m_history_length == trx_sys.rseg_history_len) {
/* No new records were added since wait started.
Simply wait for new records.The magic number 5000 is an
approximation for the case where we have cached UNDO
log records which prevent truncate of the UNDO segments.*/
return;
}
srv_wake_purge_thread_if_not_active();
if (!purge_sys.enabled() || purge_sys.paused() ||
purge_state.m_running || !trx_sys.rseg_history_len)
return;
if (purge_state.m_history_length < 5000 &&
purge_state.m_history_length == trx_sys.rseg_history_len)
/* No new records were added since wait started.
Simply wait for new records. The magic number 5000 is an
approximation for the case where we have cached UNDO
log records which prevent truncate of the UNDO segments.*/
return;
srv_wake_purge_thread_if_not_active();
}
void purge_worker_callback(void*)
static void purge_worker_callback(void*)
{
ut_ad(!current_thd);
ut_ad(!srv_read_only_mode);
ut_ad(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
void* ctx;
THD* thd = acquire_thd(&ctx);
while (srv_task_execute()){}
release_thd(thd,ctx);
ut_ad(!current_thd);
ut_ad(!srv_read_only_mode);
ut_ad(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
void *ctx;
THD *thd= acquire_thd(&ctx);
while (srv_task_execute()) {}
release_thd(thd,ctx);
}
void purge_coordinator_callback_low()
static void purge_coordinator_callback_low()
{
ulint n_total_purged = ULINT_UNDEFINED;
purge_state.m_history_length = 0;
if (!purge_sys.enabled() || purge_sys.paused()) {
return;
}
do {
n_total_purged = 0;
int sigcount = purge_state.m_running;
purge_state.m_history_length = srv_do_purge(&n_total_purged);
/* Check if purge was woken by srv_wake_purge_thread_if_not_active() */
bool woken_during_purge = purge_state.m_running > sigcount;
/*If last purge batch processed less that 1 page and there is still work to do,
delay the next batch by 10ms. Unless someone added work and woke us up. */
if (n_total_purged == 0){
if(trx_sys.rseg_history_len == 0) {
return;
}
if (!woken_during_purge) {
/* Delay next purge round*/
purge_coordinator_timer->set_time(10, 0);
return;
}
}
} while((purge_sys.enabled() && !purge_sys.paused()) || !srv_purge_should_exit());
ulint n_total_purged= ULINT_UNDEFINED;
purge_state.m_history_length= 0;
if (!purge_sys.enabled() || purge_sys.paused())
return;
do
{
n_total_purged = 0;
int sigcount= purge_state.m_running;
purge_state.m_history_length= srv_do_purge(&n_total_purged);
/* Check if purge was woken by srv_wake_purge_thread_if_not_active() */
bool woken_during_purge= purge_state.m_running > sigcount;
/* If last purge batch processed less than 1 page and there is
still work to do, delay the next batch by 10ms. Unless
someone added work and woke us up. */
if (n_total_purged == 0)
{
if (trx_sys.rseg_history_len == 0)
return;
if (!woken_during_purge)
{
/* Delay next purge round*/
purge_coordinator_timer->set_time(10, 0);
return;
}
}
}
while ((purge_sys.enabled() && !purge_sys.paused()) ||
!srv_purge_should_exit());
}
void purge_coordinator_callback(void*)
static void purge_coordinator_callback(void*)
{
void* ctx;
THD* thd = acquire_thd(&ctx);
purge_coordinator_callback_low();
release_thd(thd,ctx);
purge_state.m_running = 0;
void *ctx;
THD *thd= acquire_thd(&ctx);
purge_coordinator_callback_low();
release_thd(thd,ctx);
purge_state.m_running= 0;
}
void srv_init_purge_tasks(uint n_tasks)
{
purge_task_group.set_max_tasks(n_tasks-1);
purge_create_background_thds(n_tasks);
purge_coordinator_timer =
srv_thread_pool->create_timer(purge_coordinator_timer_callback,
nullptr);
purge_task_group.set_max_tasks(n_tasks - 1);
purge_create_background_thds(n_tasks);
purge_coordinator_timer= srv_thread_pool->create_timer
(purge_coordinator_timer_callback, nullptr);
}
void srv_shutdown_purge_tasks()
static void srv_shutdown_purge_tasks()
{
purge_coordinator_task.wait();
delete purge_coordinator_timer;
purge_coordinator_timer = nullptr;
purge_worker_task.wait();
while (!purge_thds.empty()) {
innobase_destroy_background_thd(purge_thds.front());
purge_thds.pop();
}
purge_coordinator_task.wait();
delete purge_coordinator_timer;
purge_coordinator_timer= nullptr;
purge_worker_task.wait();
while (!purge_thds.empty())
{
innobase_destroy_background_thd(purge_thds.front());
purge_thds.pop();
}
}
/**********************************************************************//**
@ -2277,12 +2261,9 @@ srv_que_task_enqueue_low(
mutex_exit(&srv_sys.tasks_mutex);
}
/**********************************************************************//**
Get count of tasks in the queue.
@return number of tasks in queue */
ulint
srv_get_task_queue_length(void)
/*===========================*/
#ifdef UNIV_DEBUG
/** @return number of tasks in queue */
ulint srv_get_task_queue_length()
{
ulint n_tasks;
@ -2296,6 +2277,7 @@ srv_get_task_queue_length(void)
return(n_tasks);
}
#endif
/** Wake up the purge coordinator. */
void
@ -2324,4 +2306,4 @@ void srv_purge_shutdown()
purge_sys.coordinator_shutdown();
srv_shutdown_purge_tasks();
}
}
}

48
storage/innobase/srv/srv0start.cc

@ -510,11 +510,7 @@ srv_undo_tablespace_create(
srv_read_only_mode ? OS_FILE_OPEN : OS_FILE_CREATE,
OS_FILE_NORMAL, OS_DATA_FILE, srv_read_only_mode, &ret);
if (srv_read_only_mode && ret) {
ib::info() << name << " opened in read-only mode";
} else if (ret == FALSE) {
if (!ret) {
if (os_file_get_last_error(false) != OS_FILE_ALREADY_EXISTS
#ifdef UNIV_AIX
/* AIX 5.1 after security patch ML7 may have
@ -527,9 +523,9 @@ srv_undo_tablespace_create(
<< name;
}
err = DB_ERROR;
} else if (srv_read_only_mode) {
ib::info() << name << " opened in read-only mode";
} else {
ut_a(!srv_read_only_mode);
/* We created the data file and now write it full of zeros */
ib::info() << "Data file " << name << " did not exist: new to"
@ -1691,7 +1687,7 @@ files_checked:
trx_sys.create();
if (create_new_db) {
ut_a(!srv_read_only_mode);
ut_ad(!srv_read_only_mode);
mtr_start(&mtr);
ut_ad(fil_system.sys_space->id == 0);
@ -2282,29 +2278,23 @@ void srv_shutdown_bg_undo_sources()
}
/**
Perform pre-shutdown task.
Since purge tasks vall into server (some MDL acqusition,
and compute virtual functions), let them shut down right
after use connections go down while the rest of the server
infrasture is still intact.
Shutdown purge to make sure that there is no possibility that we call any
plugin code (e.g., audit) inside virtual column computation.
*/
void innodb_preshutdown()
{
static bool first_time = true;
if (!first_time)
return;
first_time = false;
if (!srv_read_only_mode) {
if (!srv_fast_shutdown && srv_operation == SRV_OPERATION_NORMAL) {
while (trx_sys.any_active_transactions()) {
os_thread_sleep(1000);
}
}
srv_shutdown_bg_undo_sources();
srv_purge_shutdown();
}
static bool first_time= true;
if (!first_time)
return;
first_time= false;
if (srv_read_only_mode)
return;
if (!srv_fast_shutdown && srv_operation == SRV_OPERATION_NORMAL)
while (trx_sys.any_active_transactions())
os_thread_sleep(1000);
srv_shutdown_bg_undo_sources();
srv_purge_shutdown();
}
@ -2461,5 +2451,3 @@ srv_get_meta_data_filename(
ut_free(path);
}

39
storage/innobase/trx/trx0purge.cc

@ -173,17 +173,16 @@ void purge_sys_t::create()
mutex_create(LATCH_ID_PURGE_SYS_PQ, &pq_mutex);
truncate.current= NULL;
truncate.last= NULL;
m_initialized = true;
m_initialized= true;
}
/** Close the purge subsystem on shutdown. */
void purge_sys_t::close()
{
ut_ad(this == &purge_sys);
if (!m_initialized)
return;
ut_ad(this == &purge_sys);
ut_ad(!enabled());
trx_t* trx = query->trx;
que_graph_free(query);
@ -193,7 +192,7 @@ void purge_sys_t::close()
trx_free(trx);
rw_lock_free(&latch);
mutex_free(&pq_mutex);
m_initialized = false;
m_initialized= false;
}
/*================ UNDO LOG HISTORY LIST =============================*/
@ -1252,31 +1251,25 @@ trx_purge_dml_delay(void)
extern tpool::waitable_task purge_worker_task;
/** Wait for pending purge jobs to complete. */
static
void
trx_purge_wait_for_workers_to_complete()
static void trx_purge_wait_for_workers_to_complete()
{
purge_worker_task.wait();
/* There should be no outstanding tasks as long
as the worker threads are active. */
ut_a(srv_get_task_queue_length() == 0);
purge_worker_task.wait();
/* There should be no outstanding tasks as long
as the worker threads are active. */
ut_ad(srv_get_task_queue_length() == 0);
}
/*******************************************************************//**
This function runs a purge batch.
/**
Run a purge batch.
@param n_tasks number of purge tasks to submit to the queue
@param truncate whether to truncate the history at the end of the batch
@return number of undo log pages handled in the batch */
ulint
trx_purge(
/*======*/
ulint n_purge_threads, /*!< in: number of purge tasks
to submit to the work queue */
bool truncate /*!< in: truncate history if true */
)
ulint trx_purge(ulint n_tasks, bool truncate)
{
que_thr_t* thr = NULL;
ulint n_pages_handled;
ut_a(n_purge_threads > 0);
ut_ad(n_tasks > 0);
srv_dml_needed_delay = trx_purge_dml_delay();
@ -1291,10 +1284,10 @@ trx_purge(
#endif /* UNIV_DEBUG */
/* Fetch the UNDO recs that need to be purged. */
n_pages_handled = trx_purge_attach_undo_recs(n_purge_threads);
n_pages_handled = trx_purge_attach_undo_recs(n_tasks);
/* Submit tasks to workers queue if using multi-threaded purge. */
for (ulint i = 0; i < n_purge_threads-1; i++) {
for (ulint i = n_tasks; --i; ) {
thr = que_fork_scheduler_round_robin(purge_sys.query, thr);
ut_a(thr);
srv_que_task_enqueue_low(thr);

Loading…
Cancel
Save