Commit 40eee1da authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14614 InnoDB: Failing assertion: trx->error_state == DB_SUCCESS or lock...

MDEV-14614 InnoDB: Failing assertion: trx->error_state == DB_SUCCESS or lock wait timeout upon saving statistics

The assertion failure was caused by
MDEV-14511 Use fewer transactions for updating InnoDB persistent statistics

We are reusing a transaction object after commit, and sometimes,
even after a successful operation, the trx_t::error_state may be
something else than DB_SUCCESS. Reset the field when needed.
parent 86beb087
......@@ -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);
trx->error_state = DB_SUCCESS;
ut_d(trx->persistent_stats = true);
++trx->will_lock;
dberr_t err = dict_stats_save_defrag_stats(index, trx);
......
......@@ -213,6 +213,7 @@ dict_stats_process_entry_from_defrag_pool(trx_t* trx)
index_id_t index_id;
ut_ad(!srv_read_only_mode);
ut_ad(trx->persistent_stats);
/* pop the first index from the auto defrag pool */
if (!dict_stats_defrag_pool_get(&table_id, &index_id)) {
......@@ -242,6 +243,7 @@ dict_stats_process_entry_from_defrag_pool(trx_t* trx)
}
mutex_exit(&dict_sys->mutex);
trx->error_state = DB_SUCCESS;
++trx->will_lock;
dberr_t err = dict_stats_save_defrag_stats(index, trx);
......@@ -275,6 +277,8 @@ dict_defrag_process_entries_from_defrag_pool(trx_t* trx)
dberr_t
dict_stats_save_defrag_summary(dict_index_t* index, trx_t* trx)
{
ut_ad(trx->persistent_stats);
if (dict_index_is_ibuf(index)) {
return DB_SUCCESS;
}
......@@ -294,6 +298,9 @@ dict_stats_save_defrag_summary(dict_index_t* index, trx_t* trx)
dberr_t
dict_stats_save_defrag_stats(dict_index_t* index, trx_t* trx)
{
ut_ad(trx->error_state == DB_SUCCESS);
ut_ad(trx->persistent_stats);
if (dict_index_is_ibuf(index)) {
return DB_SUCCESS;
}
......
......@@ -378,6 +378,7 @@ dict_stats_process_entry_from_recalc_pool(trx_t* trx)
dict_stats_recalc_pool_add(table);
} else {
trx->error_state = DB_SUCCESS;
++trx->will_lock;
dict_stats_update(table, DICT_STATS_RECALC_PERSISTENT, trx);
if (trx->state != TRX_STATE_NOT_STARTED) {
......
......@@ -6480,6 +6480,7 @@ ha_innobase::open(const char* name, int, uint)
}
ut_ad(!trx->persistent_stats);
ut_d(trx->persistent_stats = true);
trx->error_state = DB_SUCCESS;
++trx->will_lock;
dict_stats_init(ib_table, trx);
innobase_commit_low(trx);
......@@ -13281,6 +13282,7 @@ create_table_info_t::create_table_update_dict()
innobase_copy_frm_flags_from_create_info(innobase_table, m_create_info);
++m_trx->will_lock;
m_trx->error_state = DB_SUCCESS;
dict_stats_update(innobase_table, DICT_STATS_EMPTY_TABLE, m_trx);
innobase_commit_low(m_trx);
......@@ -14045,6 +14047,7 @@ ha_innobase::rename_table(
normalize_table_name(norm_from, from);
normalize_table_name(norm_to, to);
trx->error_state = DB_SUCCESS;
++trx->will_lock;
ret = dict_stats_rename_table(norm_from, norm_to,
errstr, sizeof errstr, trx);
......
......@@ -9073,6 +9073,7 @@ ha_innobase::commit_inplace_alter_table(
}
row_mysql_unlock_data_dictionary(trx);
trx->error_state = DB_SUCCESS;
++trx->will_lock;
/* TODO: The following code could be executed
......
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