MDEV-25919 fixup: MSAN and Valgrind errors related to statistics
dict_table_close(): Fix a race condition around dict_stats_deinit(). This was not observed; it should have been caught by an assertion. dict_stats_deinit(): Slightly simplify the code. ha_innobase::info_low(): If the table is unreadable, initialize some dummy statistics.
This commit is contained in:
parent
c4ebfe22f9
commit
5ae5453291
@ -225,6 +225,7 @@ void dict_table_close(dict_table_t *table)
|
|||||||
if (table->release())
|
if (table->release())
|
||||||
{
|
{
|
||||||
table->stats_mutex_lock();
|
table->stats_mutex_lock();
|
||||||
|
if (table->get_ref_count() == 0)
|
||||||
dict_stats_deinit(table);
|
dict_stats_deinit(table);
|
||||||
table->stats_mutex_unlock();
|
table->stats_mutex_unlock();
|
||||||
}
|
}
|
||||||
@ -258,6 +259,7 @@ dict_table_close(
|
|||||||
that FLUSH TABLE can be used to forcibly fetch stats from disk if
|
that FLUSH TABLE can be used to forcibly fetch stats from disk if
|
||||||
they have been manually modified. */
|
they have been manually modified. */
|
||||||
table->stats_mutex_lock();
|
table->stats_mutex_lock();
|
||||||
|
if (table->get_ref_count() == 0)
|
||||||
dict_stats_deinit(table);
|
dict_stats_deinit(table);
|
||||||
table->stats_mutex_unlock();
|
table->stats_mutex_unlock();
|
||||||
}
|
}
|
||||||
|
@ -14532,7 +14532,12 @@ ha_innobase::info_low(
|
|||||||
DBUG_ASSERT(ib_table->get_ref_count() > 0);
|
DBUG_ASSERT(ib_table->get_ref_count() > 0);
|
||||||
|
|
||||||
if (!ib_table->is_readable()) {
|
if (!ib_table->is_readable()) {
|
||||||
|
ib_table->stats_mutex_lock();
|
||||||
ib_table->stat_initialized = true;
|
ib_table->stat_initialized = true;
|
||||||
|
ib_table->stat_n_rows = 0;
|
||||||
|
ib_table->stat_clustered_index_size = 0;
|
||||||
|
ib_table->stat_sum_of_other_index_sizes = 0;
|
||||||
|
ib_table->stats_mutex_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & HA_STATUS_TIME) {
|
if (flag & HA_STATUS_TIME) {
|
||||||
|
@ -175,16 +175,13 @@ dict_stats_deinit(
|
|||||||
dict_table_t* table) /*!< in/out: table */
|
dict_table_t* table) /*!< in/out: table */
|
||||||
{
|
{
|
||||||
ut_ad(table->stats_mutex_is_owner());
|
ut_ad(table->stats_mutex_is_owner());
|
||||||
|
ut_ad(table->get_ref_count() == 0);
|
||||||
|
|
||||||
ut_a(table->get_ref_count() == 0);
|
#ifdef HAVE_valgrind
|
||||||
|
|
||||||
if (!table->stat_initialized) {
|
if (!table->stat_initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
table->stat_initialized = FALSE;
|
|
||||||
|
|
||||||
#ifdef HAVE_valgrind
|
|
||||||
MEM_UNDEFINED(&table->stat_n_rows, sizeof table->stat_n_rows);
|
MEM_UNDEFINED(&table->stat_n_rows, sizeof table->stat_n_rows);
|
||||||
MEM_UNDEFINED(&table->stat_clustered_index_size,
|
MEM_UNDEFINED(&table->stat_clustered_index_size,
|
||||||
sizeof table->stat_clustered_index_size);
|
sizeof table->stat_clustered_index_size);
|
||||||
@ -218,4 +215,5 @@ dict_stats_deinit(
|
|||||||
sizeof(index->stat_n_leaf_pages));
|
sizeof(index->stat_n_leaf_pages));
|
||||||
}
|
}
|
||||||
#endif /* HAVE_valgrind */
|
#endif /* HAVE_valgrind */
|
||||||
|
table->stat_initialized = FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user