mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 12:01:42 +01:00
0bfa3dff8b
In my merge of the MySQL fix for Oracle Bug#23333990 / WL#9513 I overlooked some subsequent revisions to the test, and I also failed to notice that the test is actually always failing. Oracle introduced the parameter innodb_stats_include_delete_marked but failed to consistently take it into account in FOREIGN KEY constraints that involve CASCADE or SET NULL. When innodb_stats_include_delete_marked=ON, obviously the purge of delete-marked records should update the statistics as well. One more omission was that statistics were never updated on ROLLBACK. We are fixing that as well, properly taking into account the parameter innodb_stats_include_delete_marked. dict_stats_analyze_index_level(): Simplify an expression. (Using the ternary operator with a constant operand is unnecessary obfuscation.) page_scan_method_t: Revert the change done by Oracle. Instead, examine srv_stats_include_delete_marked directly where it is needed. dict_stats_update_if_needed(): Renamed from row_update_statistics_if_needed(). row_update_for_mysql_using_upd_graph(): Assert that the table statistics are initialized, as guaranteed by ha_innobase::open(). Update the statistics in a consistent way, both for FOREIGN KEY triggers and for the main table. If FOREIGN KEY constraints exist, do not dereference a freed pointer, but cache the proper value of node->is_delete so that it matches prebuilt->table. row_purge_record_func(): Update statistics if innodb_stats_include_delete_marked=ON. row_undo_ins(): Update statistics (on ROLLBACK of a fresh INSERT). This is independent of the parameter; the record is not delete-marked. row_undo_mod(): Update statistics on the ROLLBACK of updating key columns, or (if innodb_stats_include_delete_marked=OFF) updating delete-marks. innodb.innodb_stats_persistent: Renamed and extended from innodb.innodb_stats_del_mark. Reduced the unnecessarily large dataset from 262,144 to 32 rows. Test both values of the configuration parameter innodb_stats_include_delete_marked. Test that purge is updating the statistics. innodb_fts.innodb_fts_multiple_index: Adjust the result. The test is performing a ROLLBACK of an INSERT, which now affects the statistics. include/wait_all_purged.inc: Moved from innodb.innodb_truncate_debug to its own file.
147 lines
5.1 KiB
C
147 lines
5.1 KiB
C
/*****************************************************************************
|
|
|
|
Copyright (c) 2012, 2016, 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"
|
|
#include "os0event.h"
|
|
#include "os0thread.h"
|
|
|
|
/** 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;
|
|
|
|
#ifdef HAVE_PSI_INTERFACE
|
|
extern mysql_pfs_key_t dict_stats_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 given table from the auto recalc pool.
|
|
dict_stats_recalc_pool_del() */
|
|
void
|
|
dict_stats_recalc_pool_del(
|
|
/*=======================*/
|
|
const dict_table_t* table); /*!< in: table to remove */
|
|
|
|
/** Yield the data dictionary latch when waiting
|
|
for the background thread to stop accessing a table.
|
|
@param trx transaction holding the data dictionary locks */
|
|
#define DICT_STATS_BG_YIELD(trx) do { \
|
|
row_mysql_unlock_data_dictionary(trx); \
|
|
os_thread_sleep(250000); \
|
|
row_mysql_lock_data_dictionary(trx); \
|
|
} while (0)
|
|
|
|
/*****************************************************************//**
|
|
Request the background collection of statistics to stop for a table.
|
|
@retval true when no background process is active
|
|
@retval false when it is not safe to modify the table definition */
|
|
UNIV_INLINE
|
|
bool
|
|
dict_stats_stop_bg(
|
|
/*===============*/
|
|
dict_table_t* table) /*!< in/out: table */
|
|
{
|
|
ut_ad(!srv_read_only_mode);
|
|
ut_ad(mutex_own(&dict_sys->mutex));
|
|
|
|
if (!(table->stats_bg_flag & BG_STAT_IN_PROGRESS)) {
|
|
return(true);
|
|
}
|
|
|
|
table->stats_bg_flag |= BG_STAT_SHOULD_QUIT;
|
|
return(false);
|
|
}
|
|
|
|
/*****************************************************************//**
|
|
Wait until background stats thread has stopped using the specified table.
|
|
The caller must have locked the data dictionary using
|
|
row_mysql_lock_data_dictionary() and this function may unlock it temporarily
|
|
and restore the lock before it exits.
|
|
The background stats thread is guaranteed not to start using the specified
|
|
table after this function returns and before the caller unlocks the data
|
|
dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag
|
|
under dict_sys->mutex. */
|
|
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. */
|
|
void
|
|
dict_stats_thread_init();
|
|
/*====================*/
|
|
|
|
/*****************************************************************//**
|
|
Free resources allocated by dict_stats_thread_init(), must be called
|
|
after dict_stats_thread() has exited. */
|
|
void
|
|
dict_stats_thread_deinit();
|
|
/*======================*/
|
|
|
|
#ifdef UNIV_DEBUG
|
|
/** Disables dict stats thread. It's used by:
|
|
SET GLOBAL innodb_dict_stats_disabled_debug = 1 (0).
|
|
@param[in] thd thread handle
|
|
@param[in] var pointer to system variable
|
|
@param[out] var_ptr where the formal string goes
|
|
@param[in] save immediate result from check function */
|
|
void
|
|
dict_stats_disabled_debug_update(
|
|
THD* thd,
|
|
struct st_mysql_sys_var* var,
|
|
void* var_ptr,
|
|
const void* save);
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
/*****************************************************************//**
|
|
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"
|
|
os_thread_ret_t
|
|
DECLARE_THREAD(dict_stats_thread)(
|
|
/*==============================*/
|
|
void* arg); /*!< in: a dummy parameter
|
|
required by os_thread_create */
|
|
|
|
/** Shutdown the dict stats thread. */
|
|
void
|
|
dict_stats_shutdown();
|
|
|
|
#endif /* dict0stats_bg_h */
|