summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Mathew <jacob.mathew@mariadb.com>2018-05-21 19:17:03 -0700
committerJacob Mathew <jacob.mathew@mariadb.com>2018-05-21 19:17:03 -0700
commit519060da452925a2f8274b1d30c7518830299948 (patch)
tree3a12482db331876cf2e88de4961a975a32f418d3
parent91dfb6141f45aed5cf3fe585d8c5db86f9ddbfe9 (diff)
downloadmariadb-git-519060da452925a2f8274b1d30c7518830299948.tar.gz
MDEV-12900: spider tests failed in buildbot with valgrind
The failures with valgrind occur as a result of Spider sometimes using the wrong transaction for operations in background threads that send requests to the data nodes. The use of the wrong transaction caused the networking to the data nodes to use the wrong thread in some cases. Valgrind eventually detects this when such a thread is destroyed before it is used to disconnect from the data node by that wrong transaction when it is freed. I have fixed the problem by correcting the transaction used in each of these cases. Author: Jacob Mathew. Reviewer: Kentoku Shiba. Cherry-Picked: Commit afe5a51 on branch 10.2
-rw-r--r--storage/spider/spd_conn.cc29
-rw-r--r--storage/spider/spd_ping_table.cc22
-rw-r--r--storage/spider/spd_table.cc39
3 files changed, 7 insertions, 83 deletions
diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc
index fc3d9ecc25f..5de41ac0f98 100644
--- a/storage/spider/spd_conn.cc
+++ b/storage/spider/spd_conn.cc
@@ -69,9 +69,6 @@ extern PSI_thread_key spd_key_thd_bg_crd;
extern PSI_thread_key spd_key_thd_bg_mon;
#endif
#endif
-
-extern pthread_mutex_t spider_global_trx_mutex;
-extern SPIDER_TRX *spider_global_trx;
#endif
HASH spider_open_connections;
@@ -2807,9 +2804,6 @@ void *spider_bg_sts_action(
DBUG_RETURN(NULL);
}
share->bg_sts_thd = thd;
-/*
- spider.trx = spider_global_trx;
-*/
spider.trx = trx;
spider.share = share;
spider.conns = conns;
@@ -2922,13 +2916,11 @@ void *spider_bg_sts_action(
{
if (!conns[spider.search_link_idx])
{
- pthread_mutex_lock(&spider_global_trx_mutex);
spider_get_conn(share, spider.search_link_idx,
share->conn_keys[spider.search_link_idx],
- spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
+ trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
&error_num);
conns[spider.search_link_idx]->error_mode = 0;
- pthread_mutex_unlock(&spider_global_trx_mutex);
/*
if (
error_num &&
@@ -2937,7 +2929,7 @@ void *spider_bg_sts_action(
) {
lex_start(thd);
error_num = spider_ping_table_mon_from_table(
- spider_global_trx,
+ trx,
thd,
share,
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -2958,7 +2950,6 @@ void *spider_bg_sts_action(
}
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
{
- DBUG_ASSERT(!conns[spider.search_link_idx]->thd);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (spider_get_sts(share, spider.search_link_idx,
share->bg_sts_try_time, &spider,
@@ -2979,7 +2970,7 @@ void *spider_bg_sts_action(
) {
lex_start(thd);
error_num = spider_ping_table_mon_from_table(
- spider_global_trx,
+ trx,
thd,
share,
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -3192,9 +3183,6 @@ void *spider_bg_crd_action(
table.s = share->table_share;
table.field = share->table_share->field;
table.key_info = share->table_share->key_info;
-/*
- spider.trx = spider_global_trx;
-*/
spider.trx = trx;
spider.change_table_ptr(&table, share->table_share);
spider.share = share;
@@ -3308,13 +3296,11 @@ void *spider_bg_crd_action(
{
if (!conns[spider.search_link_idx])
{
- pthread_mutex_lock(&spider_global_trx_mutex);
spider_get_conn(share, spider.search_link_idx,
share->conn_keys[spider.search_link_idx],
- spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
+ trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
&error_num);
conns[spider.search_link_idx]->error_mode = 0;
- pthread_mutex_unlock(&spider_global_trx_mutex);
/*
if (
error_num &&
@@ -3323,7 +3309,7 @@ void *spider_bg_crd_action(
) {
lex_start(thd);
error_num = spider_ping_table_mon_from_table(
- spider_global_trx,
+ trx,
thd,
share,
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -3344,7 +3330,6 @@ void *spider_bg_crd_action(
}
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
{
- DBUG_ASSERT(!conns[spider.search_link_idx]->thd);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (spider_get_crd(share, spider.search_link_idx,
share->bg_crd_try_time, &spider, &table,
@@ -3365,7 +3350,7 @@ void *spider_bg_crd_action(
) {
lex_start(thd);
error_num = spider_ping_table_mon_from_table(
- spider_global_trx,
+ trx,
thd,
share,
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -3717,7 +3702,7 @@ void *spider_bg_mon_action(
{
lex_start(thd);
error_num = spider_ping_table_mon_from_table(
- spider_global_trx,
+ trx,
thd,
share,
(uint32) share->monitoring_sid[link_idx],
diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc
index 77a2969d061..6f04e08dc93 100644
--- a/storage/spider/spd_ping_table.cc
+++ b/storage/spider/spd_ping_table.cc
@@ -52,11 +52,6 @@ extern PSI_mutex_key spd_key_mutex_mon_list_update_status;
extern PSI_mutex_key spd_key_mutex_mon_table_cache;
#endif
-#ifndef WITHOUT_SPIDER_BG_SEARCH
-extern pthread_mutex_t spider_global_trx_mutex;
-extern SPIDER_TRX *spider_global_trx;
-#endif
-
HASH *spider_udf_table_mon_list_hash;
uint spider_udf_table_mon_list_hash_id;
const char *spider_udf_table_mon_list_hash_func_name;
@@ -130,7 +125,6 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list(
)
#endif
{
- DBUG_ASSERT(trx != spider_global_trx);
if (
table_mon_list &&
table_mon_list->mon_table_cache_version != mon_table_cache_version
@@ -608,29 +602,17 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
) {
SPIDER_CONN *conn;
DBUG_ENTER("spider_get_ping_table_tgt_conn");
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- if (trx == spider_global_trx)
- pthread_mutex_lock(&spider_global_trx_mutex);
-#endif
if (
!(conn = spider_get_conn(
share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE,
SPIDER_CONN_KIND_MYSQL, error_num))
) {
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- if (trx == spider_global_trx)
- pthread_mutex_unlock(&spider_global_trx_mutex);
-#endif
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
share->server_names[0]);
*error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
goto error;
}
#ifndef DBUG_OFF
- if (trx == spider_global_trx)
- {
- DBUG_ASSERT(!conn->thd);
- }
DBUG_PRINT("info",("spider conn->thd=%p", conn->thd));
if (conn->thd)
{
@@ -638,10 +620,6 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
}
#endif
conn->error_mode = 0;
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- if (trx == spider_global_trx)
- pthread_mutex_unlock(&spider_global_trx_mutex);
-#endif
DBUG_RETURN(conn);
error:
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 2f666fef2f4..130edc5ee8a 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -98,9 +98,6 @@ PSI_mutex_key spd_key_mutex_conn;
PSI_mutex_key spd_key_mutex_hs_r_conn;
PSI_mutex_key spd_key_mutex_hs_w_conn;
#endif
-#ifndef WITHOUT_SPIDER_BG_SEARCH
-PSI_mutex_key spd_key_mutex_global_trx;
-#endif
PSI_mutex_key spd_key_mutex_open_conn;
PSI_mutex_key spd_key_mutex_allocated_thds;
PSI_mutex_key spd_key_mutex_mon_table_cache;
@@ -145,9 +142,6 @@ static PSI_mutex_info all_spider_mutexes[]=
{ &spd_key_mutex_hs_r_conn, "hs_r_conn", PSI_FLAG_GLOBAL},
{ &spd_key_mutex_hs_w_conn, "hs_w_conn", PSI_FLAG_GLOBAL},
#endif
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- { &spd_key_mutex_global_trx, "global_trx", PSI_FLAG_GLOBAL},
-#endif
{ &spd_key_mutex_open_conn, "open_conn", PSI_FLAG_GLOBAL},
{ &spd_key_mutex_allocated_thds, "allocated_thds", PSI_FLAG_GLOBAL},
{ &spd_key_mutex_mon_table_cache, "mon_table_cache", PSI_FLAG_GLOBAL},
@@ -301,9 +295,6 @@ pthread_mutex_t spider_allocated_thds_mutex;
#ifndef WITHOUT_SPIDER_BG_SEARCH
pthread_attr_t spider_pt_attr;
-
-pthread_mutex_t spider_global_trx_mutex;
-SPIDER_TRX *spider_global_trx;
#endif
extern pthread_mutex_t spider_mem_calc_mutex;
@@ -6090,10 +6081,6 @@ int spider_db_done(
do_delete_thd = TRUE;
}
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- spider_free_trx(spider_global_trx, TRUE);
-#endif
-
for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; roop_count--)
{
if (spider_dbton[roop_count].deinit)
@@ -6261,9 +6248,6 @@ int spider_db_done(
pthread_mutex_destroy(&spider_mon_table_cache_mutex);
pthread_mutex_destroy(&spider_allocated_thds_mutex);
pthread_mutex_destroy(&spider_open_conn_mutex);
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- pthread_mutex_destroy(&spider_global_trx_mutex);
-#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
pthread_mutex_destroy(&spider_hs_w_conn_mutex);
pthread_mutex_destroy(&spider_hs_r_conn_mutex);
@@ -6510,18 +6494,6 @@ int spider_db_init(
error_num = HA_ERR_OUT_OF_MEM;
goto error_conn_mutex_init;
}
-#ifndef WITHOUT_SPIDER_BG_SEARCH
-#if MYSQL_VERSION_ID < 50500
- if (pthread_mutex_init(&spider_global_trx_mutex, MY_MUTEX_INIT_FAST))
-#else
- if (mysql_mutex_init(spd_key_mutex_global_trx,
- &spider_global_trx_mutex, MY_MUTEX_INIT_FAST))
-#endif
- {
- error_num = HA_ERR_OUT_OF_MEM;
- goto error_global_trx_mutex_init;
- }
-#endif
#if MYSQL_VERSION_ID < 50500
if (pthread_mutex_init(&spider_open_conn_mutex, MY_MUTEX_INIT_FAST))
#else
@@ -6786,16 +6758,9 @@ int spider_db_init(
}
}
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- if (!(spider_global_trx = spider_get_trx(NULL, FALSE, &error_num)))
- goto error;
-#endif
-
DBUG_RETURN(0);
#ifndef WITHOUT_SPIDER_BG_SEARCH
-error:
- roop_count = SPIDER_DBTON_SIZE;
error_init_dbton:
for (roop_count--; roop_count >= 0; roop_count--)
{
@@ -6897,10 +6862,6 @@ error_hs_r_conn_mutex_init:
#endif
pthread_mutex_destroy(&spider_open_conn_mutex);
error_open_conn_mutex_init:
-#ifndef WITHOUT_SPIDER_BG_SEARCH
- pthread_mutex_destroy(&spider_global_trx_mutex);
-error_global_trx_mutex_init:
-#endif
pthread_mutex_destroy(&spider_conn_mutex);
error_conn_mutex_init:
pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex);