/***************************************************************************** Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2017, 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, Suite 500, 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 "univ.i" #include "dict0types.h" /* dict_table_t, table_id_t */ #include "os0sync.h" /* os_event_t */ #include "os0thread.h" /* DECLARE_THREAD */ /** Event to wake up dict_stats_thread on dict_stats_recalc_pool_add() or shutdown. Not protected by any mutex. */ extern os_event_t dict_stats_event; /*****************************************************************//** Add a table to the recalc pool, which is processed by the background stats gathering thread. Only the table id is added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table does not exist later (has been DROPped), then it will be removed from the pool and skipped. */ UNIV_INTERN void dict_stats_recalc_pool_add( /*=======================*/ const dict_table_t* table); /*!< in: table to add */ /*****************************************************************//** Delete a given table from the auto recalc pool. dict_stats_recalc_pool_del() */ UNIV_INTERN void dict_stats_recalc_pool_del( /*=======================*/ const dict_table_t* table); /*!< in: table to remove */ /*****************************************************************//** Add an index in a table to the defrag pool, which is processed by the background stats gathering thread. Only the table id and index id are added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table or index does not exist later (has been DROPped), then it will be removed from the pool and skipped. */ UNIV_INTERN void dict_stats_defrag_pool_add( /*=======================*/ const dict_index_t* index); /*!< in: table to add */ /*****************************************************************//** Delete a given index from the auto defrag pool. */ UNIV_INTERN void dict_stats_defrag_pool_del( /*=======================*/ const dict_table_t* table, /*!stats_bg_flag under dict_sys->mutex. */ UNIV_INTERN void dict_stats_wait_bg_to_stop_using_table( /*===================================*/ dict_table_t* table, /*!< in/out: table */ trx_t* trx); /*!< in/out: transaction to use for unlocking/locking the data dict */ /*****************************************************************//** Initialize global variables needed for the operation of dict_stats_thread(). Must be called before dict_stats_thread() is started. */ UNIV_INTERN void dict_stats_thread_init(); /*====================*/ /*****************************************************************//** Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited. */ UNIV_INTERN void dict_stats_thread_deinit(); /*======================*/ /*****************************************************************//** This is the thread for background stats gathering. It pops tables, from the auto recalc list and proceeds them, eventually recalculating their statistics. @return this function does not return, it calls os_thread_exit() */ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(dict_stats_thread)( /*==============================*/ void* arg); /*!< in: a dummy parameter required by os_thread_create */ /** Shut down the dict_stats_thread. */ void dict_stats_shutdown(); # ifndef UNIV_NONINL # include "dict0stats_bg.ic" # endif #endif /* dict0stats_bg_h */