mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Follow-up fix to MDEV-13201 Assertion srv_undo_sources || ...
failed on shutdown during DDL operation
Introduce the debug flag trx_t::persistent_stats to suppress the assertion for the updates of persistent statistics during fast shutdown. dict_stats_exec_sql(): Do execute the statement even though shutdown has been initiated.
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Persistent statistics do not exist");
|
|
||||||
SET GLOBAL innodb_stats_persistent= ON;
|
SET GLOBAL innodb_stats_persistent= ON;
|
||||||
CREATE TABLE t1 (t TEXT) ENGINE=InnoDB;
|
CREATE TABLE t1 (t TEXT) ENGINE=InnoDB STATS_PERSISTENT=1;
|
||||||
connect con1,localhost,root,,test;
|
connect con1,localhost,root,,test;
|
||||||
SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
|
SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
|
||||||
TRUNCATE TABLE t1;
|
TRUNCATE TABLE t1;
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
--source include/have_debug.inc
|
--source include/have_debug.inc
|
||||||
--source include/have_debug_sync.inc
|
--source include/have_debug_sync.inc
|
||||||
|
|
||||||
call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Persistent statistics do not exist");
|
|
||||||
|
|
||||||
SET GLOBAL innodb_stats_persistent= ON;
|
SET GLOBAL innodb_stats_persistent= ON;
|
||||||
CREATE TABLE t1 (t TEXT) ENGINE=InnoDB;
|
CREATE TABLE t1 (t TEXT) ENGINE=InnoDB STATS_PERSISTENT=1;
|
||||||
--connect (con1,localhost,root,,test)
|
--connect (con1,localhost,root,,test)
|
||||||
SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
|
SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
|
||||||
--send
|
--send
|
||||||
|
@ -831,6 +831,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
|
|||||||
mtr_commit(&mtr);
|
mtr_commit(&mtr);
|
||||||
/* Reaching the end of the index. */
|
/* Reaching the end of the index. */
|
||||||
dict_stats_empty_defrag_stats(index);
|
dict_stats_empty_defrag_stats(index);
|
||||||
|
ut_d(trx->persistent_stats = true);
|
||||||
++trx->will_lock;
|
++trx->will_lock;
|
||||||
dberr_t err = dict_stats_save_defrag_stats(index, trx);
|
dberr_t err = dict_stats_save_defrag_stats(index, trx);
|
||||||
if (err == DB_SUCCESS) {
|
if (err == DB_SUCCESS) {
|
||||||
@ -849,6 +850,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
|
|||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ut_d(trx->persistent_stats = false);
|
||||||
btr_defragment_remove_item(item);
|
btr_defragment_remove_item(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,14 +287,6 @@ dict_stats_exec_sql(
|
|||||||
{
|
{
|
||||||
dberr_t err;
|
dberr_t err;
|
||||||
|
|
||||||
extern bool dict_stats_start_shutdown;
|
|
||||||
|
|
||||||
if (dict_stats_start_shutdown
|
|
||||||
|| !dict_stats_persistent_storage_check(true)) {
|
|
||||||
pars_info_free(pinfo);
|
|
||||||
return(DB_STATS_DO_NOT_EXIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
err = que_eval_sql(pinfo, sql, FALSE, trx); /* pinfo is freed here */
|
err = que_eval_sql(pinfo, sql, FALSE, trx); /* pinfo is freed here */
|
||||||
|
|
||||||
DBUG_EXECUTE_IF("stats_index_error",
|
DBUG_EXECUTE_IF("stats_index_error",
|
||||||
@ -2276,6 +2268,8 @@ dict_stats_save_index_stat(
|
|||||||
char db_utf8[MAX_DB_UTF8_LEN];
|
char db_utf8[MAX_DB_UTF8_LEN];
|
||||||
char table_utf8[MAX_TABLE_UTF8_LEN];
|
char table_utf8[MAX_TABLE_UTF8_LEN];
|
||||||
|
|
||||||
|
ut_ad(trx->persistent_stats || trx->in_mysql_trx_list);
|
||||||
|
|
||||||
dict_fs2utf8(index->table->name.m_name, db_utf8, sizeof(db_utf8),
|
dict_fs2utf8(index->table->name.m_name, db_utf8, sizeof(db_utf8),
|
||||||
table_utf8, sizeof(table_utf8));
|
table_utf8, sizeof(table_utf8));
|
||||||
|
|
||||||
@ -2401,6 +2395,8 @@ dict_stats_save(
|
|||||||
char db_utf8[MAX_DB_UTF8_LEN];
|
char db_utf8[MAX_DB_UTF8_LEN];
|
||||||
char table_utf8[MAX_TABLE_UTF8_LEN];
|
char table_utf8[MAX_TABLE_UTF8_LEN];
|
||||||
|
|
||||||
|
ut_ad(trx->persistent_stats || trx->in_mysql_trx_list);
|
||||||
|
|
||||||
if (table_orig->is_readable()) {
|
if (table_orig->is_readable()) {
|
||||||
} else {
|
} else {
|
||||||
return (dict_stats_report_error(table_orig));
|
return (dict_stats_report_error(table_orig));
|
||||||
|
@ -444,6 +444,7 @@ DECLARE_THREAD(dict_stats_thread)(void*)
|
|||||||
#endif /* UNIV_PFS_THREAD */
|
#endif /* UNIV_PFS_THREAD */
|
||||||
|
|
||||||
trx_t* trx = trx_allocate_for_background();
|
trx_t* trx = trx_allocate_for_background();
|
||||||
|
ut_d(trx->persistent_stats = true);
|
||||||
|
|
||||||
while (!dict_stats_start_shutdown) {
|
while (!dict_stats_start_shutdown) {
|
||||||
|
|
||||||
@ -476,6 +477,7 @@ DECLARE_THREAD(dict_stats_thread)(void*)
|
|||||||
os_event_reset(dict_stats_event);
|
os_event_reset(dict_stats_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ut_d(trx->persistent_stats = false);
|
||||||
trx_free_for_background(trx);
|
trx_free_for_background(trx);
|
||||||
srv_dict_stats_thread_active = false;
|
srv_dict_stats_thread_active = false;
|
||||||
|
|
||||||
|
@ -6468,9 +6468,12 @@ no_such_table:
|
|||||||
if (alloc) {
|
if (alloc) {
|
||||||
trx = trx_allocate_for_background();
|
trx = trx_allocate_for_background();
|
||||||
}
|
}
|
||||||
|
ut_ad(!trx->persistent_stats);
|
||||||
|
ut_d(trx->persistent_stats = true);
|
||||||
++trx->will_lock;
|
++trx->will_lock;
|
||||||
dict_stats_init(ib_table, trx);
|
dict_stats_init(ib_table, trx);
|
||||||
innobase_commit_low(trx);
|
innobase_commit_low(trx);
|
||||||
|
ut_d(trx->persistent_stats = false);
|
||||||
if (alloc) {
|
if (alloc) {
|
||||||
trx_free_for_background(trx);
|
trx_free_for_background(trx);
|
||||||
}
|
}
|
||||||
@ -14592,6 +14595,7 @@ ha_innobase::info_low(
|
|||||||
on the mysql.innodb_table_stats,
|
on the mysql.innodb_table_stats,
|
||||||
mysql.innodb_index_stats tables. */
|
mysql.innodb_index_stats tables. */
|
||||||
trx_t* trx = trx_allocate_for_background();
|
trx_t* trx = trx_allocate_for_background();
|
||||||
|
ut_d(trx->persistent_stats = true);
|
||||||
++trx->will_lock;
|
++trx->will_lock;
|
||||||
ret = dict_stats_update(ib_table, opt, trx);
|
ret = dict_stats_update(ib_table, opt, trx);
|
||||||
|
|
||||||
@ -14604,6 +14608,7 @@ ha_innobase::info_low(
|
|||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ut_d(trx->persistent_stats = false);
|
||||||
trx_free_for_background(trx);
|
trx_free_for_background(trx);
|
||||||
|
|
||||||
if (ret != DB_SUCCESS) {
|
if (ret != DB_SUCCESS) {
|
||||||
|
@ -1123,6 +1123,9 @@ struct trx_t {
|
|||||||
mysql_trx_list; /*!< list of transactions created for
|
mysql_trx_list; /*!< list of transactions created for
|
||||||
MySQL; protected by trx_sys->mutex */
|
MySQL; protected by trx_sys->mutex */
|
||||||
#ifdef UNIV_DEBUG
|
#ifdef UNIV_DEBUG
|
||||||
|
/** whether this transaction is updating persistent statistics
|
||||||
|
(used for silencing a debug assertion at shutdown) */
|
||||||
|
bool persistent_stats;
|
||||||
bool in_mysql_trx_list;
|
bool in_mysql_trx_list;
|
||||||
/*!< true if in
|
/*!< true if in
|
||||||
trx_sys->mysql_trx_list */
|
trx_sys->mysql_trx_list */
|
||||||
|
@ -301,7 +301,8 @@ trx_purge_add_update_undo_to_history(
|
|||||||
&& purge_sys->state == PURGE_STATE_INIT)
|
&& purge_sys->state == PURGE_STATE_INIT)
|
||||||
|| (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND
|
|| (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND
|
||||||
&& purge_sys->state == PURGE_STATE_DISABLED)
|
&& purge_sys->state == PURGE_STATE_DISABLED)
|
||||||
|| ((trx->undo_no == 0 || trx->in_mysql_trx_list)
|
|| ((trx->undo_no == 0 || trx->in_mysql_trx_list
|
||||||
|
|| trx->persistent_stats)
|
||||||
&& srv_fast_shutdown));
|
&& srv_fast_shutdown));
|
||||||
|
|
||||||
/* Add the log as the first in the history list */
|
/* Add the log as the first in the history list */
|
||||||
|
@ -553,6 +553,7 @@ trx_validate_state_before_free(trx_t* trx)
|
|||||||
ut_ad(!trx->declared_to_be_inside_innodb);
|
ut_ad(!trx->declared_to_be_inside_innodb);
|
||||||
ut_ad(!trx->n_mysql_tables_in_use);
|
ut_ad(!trx->n_mysql_tables_in_use);
|
||||||
ut_ad(!trx->mysql_n_tables_locked);
|
ut_ad(!trx->mysql_n_tables_locked);
|
||||||
|
ut_ad(!trx->persistent_stats);
|
||||||
|
|
||||||
if (trx->declared_to_be_inside_innodb) {
|
if (trx->declared_to_be_inside_innodb) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user