summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2022-09-06 22:35:03 +0900
committerNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2022-09-27 23:29:16 +0900
commitf956e73c5727ad8c37b28d97926d1ae634be82b9 (patch)
tree7d0760626a101270e9f2e9bc1121f1d96d0c68ce
parente3fdabd501d9b8efaf0ca65f930af438f7fe993f (diff)
downloadmariadb-git-bb-10.4-MDEV-29456.tar.gz
MDEV-29421 Thread (10.6+) and server hangs (10.4/10.5) in 'Opening tables' (on optimized builds) and SIGABRT in safe_mutex_lock (on debug) on I_S read when using Spiderbb-10.4-MDEV-29456
In spider_free_share(), Spider acquires the mutex, spider_open_tables, and then makes statistics of the target table persistent. When table_open_cache is small, the statistics persistence can lead to another call of spider_free_share() and this results in the double lock on the mutex. The mutex spider_tbl_mutex is acquired unnecessarily long. Shortening the locking period resolves the problem.
-rw-r--r--storage/spider/spd_table.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 7a00061e3a2..408515810b7 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -5804,11 +5804,23 @@ int spider_free_share(
SPIDER_SHARE *share
) {
DBUG_ENTER("spider_free_share");
- pthread_mutex_lock(&spider_tbl_mutex);
bool do_delete_thd = false;
THD *thd = current_thd;
- if (!--share->use_count)
+ pthread_mutex_lock(&spider_tbl_mutex);
+ if (--share->use_count)
+ {
+ pthread_mutex_unlock(&spider_tbl_mutex);
+ }
+ else
{
+#ifdef HASH_UPDATE_WITH_HASH_VALUE
+ my_hash_delete_with_hash_value(&spider_open_tables,
+ share->table_name_hash_value, (uchar*) share);
+#else
+ my_hash_delete(&spider_open_tables, (uchar*) share);
+#endif
+ pthread_mutex_unlock(&spider_tbl_mutex);
+
#ifndef WITHOUT_SPIDER_BG_SEARCH
spider_free_sts_thread(share);
spider_free_crd_thread(share);
@@ -5866,12 +5878,6 @@ int spider_free_share(
);
}
spider_free_share_alloc(share);
-#ifdef HASH_UPDATE_WITH_HASH_VALUE
- my_hash_delete_with_hash_value(&spider_open_tables,
- share->table_name_hash_value, (uchar*) share);
-#else
- my_hash_delete(&spider_open_tables, (uchar*) share);
-#endif
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->crd_mutex);
pthread_mutex_destroy(&share->sts_mutex);
@@ -5881,7 +5887,6 @@ int spider_free_share(
}
if (do_delete_thd)
spider_destroy_thd(thd);
- pthread_mutex_unlock(&spider_tbl_mutex);
DBUG_RETURN(0);
}