Commit 77fb7ccb authored by Marko Mäkelä's avatar Marko Mäkelä

Follow-up fix to MDEV-13201 Assertion `srv_undo_sources || ...` failed on...

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.
parent 7dc6066d
call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Persistent statistics do not exist");
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;
SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
TRUNCATE TABLE t1;
......
......@@ -2,10 +2,8 @@
--source include/have_debug.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;
CREATE TABLE t1 (t TEXT) ENGINE=InnoDB;
CREATE TABLE t1 (t TEXT) ENGINE=InnoDB STATS_PERSISTENT=1;
--connect (con1,localhost,root,,test)
SET DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL committed WAIT_FOR ever';
--send
......
......@@ -831,6 +831,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
mtr_commit(&mtr);
/* Reaching the end of the index. */
dict_stats_empty_defrag_stats(index);
ut_d(trx->persistent_stats = true);
++trx->will_lock;
dberr_t err = dict_stats_save_defrag_stats(index, trx);
if (err == DB_SUCCESS) {
......@@ -849,6 +850,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
trx_commit_for_mysql(trx);
}
ut_d(trx->persistent_stats = false);
btr_defragment_remove_item(item);
}
}
......
......@@ -287,14 +287,6 @@ dict_stats_exec_sql(
{
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 */
DBUG_EXECUTE_IF("stats_index_error",
......@@ -2276,6 +2268,8 @@ dict_stats_save_index_stat(
char db_utf8[MAX_DB_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),
table_utf8, sizeof(table_utf8));
......@@ -2401,6 +2395,8 @@ dict_stats_save(
char db_utf8[MAX_DB_UTF8_LEN];
char table_utf8[MAX_TABLE_UTF8_LEN];
ut_ad(trx->persistent_stats || trx->in_mysql_trx_list);
if (table_orig->is_readable()) {
} else {
return (dict_stats_report_error(table_orig));
......
......@@ -444,6 +444,7 @@ DECLARE_THREAD(dict_stats_thread)(void*)
#endif /* UNIV_PFS_THREAD */
trx_t* trx = trx_allocate_for_background();
ut_d(trx->persistent_stats = true);
while (!dict_stats_start_shutdown) {
......@@ -476,6 +477,7 @@ DECLARE_THREAD(dict_stats_thread)(void*)
os_event_reset(dict_stats_event);
}
ut_d(trx->persistent_stats = false);
trx_free_for_background(trx);
srv_dict_stats_thread_active = false;
......
......@@ -6468,9 +6468,12 @@ ha_innobase::open(const char* name, int, uint)
if (alloc) {
trx = trx_allocate_for_background();
}
ut_ad(!trx->persistent_stats);
ut_d(trx->persistent_stats = true);
++trx->will_lock;
dict_stats_init(ib_table, trx);
innobase_commit_low(trx);
ut_d(trx->persistent_stats = false);
if (alloc) {
trx_free_for_background(trx);
}
......@@ -14592,6 +14595,7 @@ ha_innobase::info_low(
on the mysql.innodb_table_stats,
mysql.innodb_index_stats tables. */
trx_t* trx = trx_allocate_for_background();
ut_d(trx->persistent_stats = true);
++trx->will_lock;
ret = dict_stats_update(ib_table, opt, trx);
......@@ -14604,6 +14608,7 @@ ha_innobase::info_low(
trx_commit_for_mysql(trx);
}
ut_d(trx->persistent_stats = false);
trx_free_for_background(trx);
if (ret != DB_SUCCESS) {
......
......@@ -1123,6 +1123,9 @@ struct trx_t {
mysql_trx_list; /*!< list of transactions created for
MySQL; protected by trx_sys->mutex */
#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;
/*!< true if in
trx_sys->mysql_trx_list */
......
......@@ -301,7 +301,8 @@ trx_purge_add_update_undo_to_history(
&& purge_sys->state == PURGE_STATE_INIT)
|| (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND
&& 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));
/* 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->n_mysql_tables_in_use);
ut_ad(!trx->mysql_n_tables_locked);
ut_ad(!trx->persistent_stats);
if (trx->declared_to_be_inside_innodb) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment