mirror of
https://github.com/MariaDB/server.git
synced 2025-11-11 16:26:13 +01:00
The purpose of dict_table_t::stats_bg_flag was to prevent race conditions between DDL operations and a background thread that updates persistent statistics for InnoDB tables. Now that with the parent commit, we started to acquire a shared meta-data lock (MDL) on the InnoDB persistent statistics tables in background tasks that access them, we may easily acquire MDL on the table for which the statistics are being updated. This will by design prevent race conditions with any DDL operations on that table, and the stats_bg_flag may be removed. dict_stats_process_entry_from_recalc_pool(): Complete rewrite. During the processing, retain the entry in recalc_pool, so that dict_stats_recalc_pool_del() will be able to request deletion of the entry, or delete the entry if its caller is holding MDL_EXCLUSIVE while we are waiting for MDL. recalc_pool: In addition to the table ID, store a state for inter-thread communication, so that dict_stats_recalc_pool_del() can wait until all processing is finished. Reviewed by: Thirunarayanan Balathandayuthapani
73 lines
2.6 KiB
C
73 lines
2.6 KiB
C
/*****************************************************************************
|
|
|
|
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved.
|
|
Copyright (c) 2017, 2021, 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
|
|
Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
/**************************************************//**
|
|
@file include/dict0stats_bg.h
|
|
Code used for background table and index stats gathering.
|
|
|
|
Created Apr 26, 2012 Vasil Dimov
|
|
*******************************************************/
|
|
|
|
#ifndef dict0stats_bg_h
|
|
#define dict0stats_bg_h
|
|
|
|
#include "dict0types.h"
|
|
#include "os0thread.h"
|
|
|
|
#ifdef HAVE_PSI_INTERFACE
|
|
extern mysql_pfs_key_t recalc_pool_mutex_key;
|
|
#endif /* HAVE_PSI_INTERFACE */
|
|
|
|
#ifdef UNIV_DEBUG
|
|
/** Value of MySQL global used to disable dict_stats thread. */
|
|
extern my_bool innodb_dict_stats_disabled_debug;
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
/** Delete a table from the auto recalc pool, and ensure that
|
|
no statistics are being updated on it. */
|
|
void dict_stats_recalc_pool_del(table_id_t id, bool have_mdl_exclusive);
|
|
|
|
/*****************************************************************//**
|
|
Initialize global variables needed for the operation of dict_stats_thread().
|
|
Must be called before dict_stats task is started. */
|
|
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();
|
|
|
|
#ifdef UNIV_DEBUG
|
|
/** Disables dict stats thread. It's used by:
|
|
SET GLOBAL innodb_dict_stats_disabled_debug = 1 (0).
|
|
@param[in] save immediate result from check function */
|
|
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();
|
|
|
|
/** Shut down the dict_stats timer. */
|
|
void dict_stats_shutdown();
|
|
|
|
/** Reschedule dict stats timer to run now. */
|
|
void dict_stats_schedule_now();
|
|
|
|
#endif /* dict0stats_bg_h */
|