Skip to content

Commit 519060d

Browse files
author
Jacob Mathew
committed
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
1 parent 91dfb61 commit 519060d

File tree

3 files changed

+7
-83
lines changed

3 files changed

+7
-83
lines changed

storage/spider/spd_conn.cc

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ extern PSI_thread_key spd_key_thd_bg_crd;
6969
extern PSI_thread_key spd_key_thd_bg_mon;
7070
#endif
7171
#endif
72-
73-
extern pthread_mutex_t spider_global_trx_mutex;
74-
extern SPIDER_TRX *spider_global_trx;
7572
#endif
7673

7774
HASH spider_open_connections;
@@ -2807,9 +2804,6 @@ void *spider_bg_sts_action(
28072804
DBUG_RETURN(NULL);
28082805
}
28092806
share->bg_sts_thd = thd;
2810-
/*
2811-
spider.trx = spider_global_trx;
2812-
*/
28132807
spider.trx = trx;
28142808
spider.share = share;
28152809
spider.conns = conns;
@@ -2922,13 +2916,11 @@ void *spider_bg_sts_action(
29222916
{
29232917
if (!conns[spider.search_link_idx])
29242918
{
2925-
pthread_mutex_lock(&spider_global_trx_mutex);
29262919
spider_get_conn(share, spider.search_link_idx,
29272920
share->conn_keys[spider.search_link_idx],
2928-
spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
2921+
trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
29292922
&error_num);
29302923
conns[spider.search_link_idx]->error_mode = 0;
2931-
pthread_mutex_unlock(&spider_global_trx_mutex);
29322924
/*
29332925
if (
29342926
error_num &&
@@ -2937,7 +2929,7 @@ void *spider_bg_sts_action(
29372929
) {
29382930
lex_start(thd);
29392931
error_num = spider_ping_table_mon_from_table(
2940-
spider_global_trx,
2932+
trx,
29412933
thd,
29422934
share,
29432935
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -2958,7 +2950,6 @@ void *spider_bg_sts_action(
29582950
}
29592951
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
29602952
{
2961-
DBUG_ASSERT(!conns[spider.search_link_idx]->thd);
29622953
#ifdef WITH_PARTITION_STORAGE_ENGINE
29632954
if (spider_get_sts(share, spider.search_link_idx,
29642955
share->bg_sts_try_time, &spider,
@@ -2979,7 +2970,7 @@ void *spider_bg_sts_action(
29792970
) {
29802971
lex_start(thd);
29812972
error_num = spider_ping_table_mon_from_table(
2982-
spider_global_trx,
2973+
trx,
29832974
thd,
29842975
share,
29852976
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -3192,9 +3183,6 @@ void *spider_bg_crd_action(
31923183
table.s = share->table_share;
31933184
table.field = share->table_share->field;
31943185
table.key_info = share->table_share->key_info;
3195-
/*
3196-
spider.trx = spider_global_trx;
3197-
*/
31983186
spider.trx = trx;
31993187
spider.change_table_ptr(&table, share->table_share);
32003188
spider.share = share;
@@ -3308,13 +3296,11 @@ void *spider_bg_crd_action(
33083296
{
33093297
if (!conns[spider.search_link_idx])
33103298
{
3311-
pthread_mutex_lock(&spider_global_trx_mutex);
33123299
spider_get_conn(share, spider.search_link_idx,
33133300
share->conn_keys[spider.search_link_idx],
3314-
spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
3301+
trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
33153302
&error_num);
33163303
conns[spider.search_link_idx]->error_mode = 0;
3317-
pthread_mutex_unlock(&spider_global_trx_mutex);
33183304
/*
33193305
if (
33203306
error_num &&
@@ -3323,7 +3309,7 @@ void *spider_bg_crd_action(
33233309
) {
33243310
lex_start(thd);
33253311
error_num = spider_ping_table_mon_from_table(
3326-
spider_global_trx,
3312+
trx,
33273313
thd,
33283314
share,
33293315
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -3344,7 +3330,6 @@ void *spider_bg_crd_action(
33443330
}
33453331
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
33463332
{
3347-
DBUG_ASSERT(!conns[spider.search_link_idx]->thd);
33483333
#ifdef WITH_PARTITION_STORAGE_ENGINE
33493334
if (spider_get_crd(share, spider.search_link_idx,
33503335
share->bg_crd_try_time, &spider, &table,
@@ -3365,7 +3350,7 @@ void *spider_bg_crd_action(
33653350
) {
33663351
lex_start(thd);
33673352
error_num = spider_ping_table_mon_from_table(
3368-
spider_global_trx,
3353+
trx,
33693354
thd,
33703355
share,
33713356
(uint32) share->monitoring_sid[spider.search_link_idx],
@@ -3717,7 +3702,7 @@ void *spider_bg_mon_action(
37173702
{
37183703
lex_start(thd);
37193704
error_num = spider_ping_table_mon_from_table(
3720-
spider_global_trx,
3705+
trx,
37213706
thd,
37223707
share,
37233708
(uint32) share->monitoring_sid[link_idx],

storage/spider/spd_ping_table.cc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ extern PSI_mutex_key spd_key_mutex_mon_list_update_status;
5252
extern PSI_mutex_key spd_key_mutex_mon_table_cache;
5353
#endif
5454

55-
#ifndef WITHOUT_SPIDER_BG_SEARCH
56-
extern pthread_mutex_t spider_global_trx_mutex;
57-
extern SPIDER_TRX *spider_global_trx;
58-
#endif
59-
6055
HASH *spider_udf_table_mon_list_hash;
6156
uint spider_udf_table_mon_list_hash_id;
6257
const char *spider_udf_table_mon_list_hash_func_name;
@@ -130,7 +125,6 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list(
130125
)
131126
#endif
132127
{
133-
DBUG_ASSERT(trx != spider_global_trx);
134128
if (
135129
table_mon_list &&
136130
table_mon_list->mon_table_cache_version != mon_table_cache_version
@@ -608,40 +602,24 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
608602
) {
609603
SPIDER_CONN *conn;
610604
DBUG_ENTER("spider_get_ping_table_tgt_conn");
611-
#ifndef WITHOUT_SPIDER_BG_SEARCH
612-
if (trx == spider_global_trx)
613-
pthread_mutex_lock(&spider_global_trx_mutex);
614-
#endif
615605
if (
616606
!(conn = spider_get_conn(
617607
share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE,
618608
SPIDER_CONN_KIND_MYSQL, error_num))
619609
) {
620-
#ifndef WITHOUT_SPIDER_BG_SEARCH
621-
if (trx == spider_global_trx)
622-
pthread_mutex_unlock(&spider_global_trx_mutex);
623-
#endif
624610
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
625611
share->server_names[0]);
626612
*error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
627613
goto error;
628614
}
629615
#ifndef DBUG_OFF
630-
if (trx == spider_global_trx)
631-
{
632-
DBUG_ASSERT(!conn->thd);
633-
}
634616
DBUG_PRINT("info",("spider conn->thd=%p", conn->thd));
635617
if (conn->thd)
636618
{
637619
DBUG_PRINT("info",("spider query_id=%lld", conn->thd->query_id));
638620
}
639621
#endif
640622
conn->error_mode = 0;
641-
#ifndef WITHOUT_SPIDER_BG_SEARCH
642-
if (trx == spider_global_trx)
643-
pthread_mutex_unlock(&spider_global_trx_mutex);
644-
#endif
645623
DBUG_RETURN(conn);
646624

647625
error:

storage/spider/spd_table.cc

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ PSI_mutex_key spd_key_mutex_conn;
9898
PSI_mutex_key spd_key_mutex_hs_r_conn;
9999
PSI_mutex_key spd_key_mutex_hs_w_conn;
100100
#endif
101-
#ifndef WITHOUT_SPIDER_BG_SEARCH
102-
PSI_mutex_key spd_key_mutex_global_trx;
103-
#endif
104101
PSI_mutex_key spd_key_mutex_open_conn;
105102
PSI_mutex_key spd_key_mutex_allocated_thds;
106103
PSI_mutex_key spd_key_mutex_mon_table_cache;
@@ -144,9 +141,6 @@ static PSI_mutex_info all_spider_mutexes[]=
144141
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
145142
{ &spd_key_mutex_hs_r_conn, "hs_r_conn", PSI_FLAG_GLOBAL},
146143
{ &spd_key_mutex_hs_w_conn, "hs_w_conn", PSI_FLAG_GLOBAL},
147-
#endif
148-
#ifndef WITHOUT_SPIDER_BG_SEARCH
149-
{ &spd_key_mutex_global_trx, "global_trx", PSI_FLAG_GLOBAL},
150144
#endif
151145
{ &spd_key_mutex_open_conn, "open_conn", PSI_FLAG_GLOBAL},
152146
{ &spd_key_mutex_allocated_thds, "allocated_thds", PSI_FLAG_GLOBAL},
@@ -301,9 +295,6 @@ pthread_mutex_t spider_allocated_thds_mutex;
301295

302296
#ifndef WITHOUT_SPIDER_BG_SEARCH
303297
pthread_attr_t spider_pt_attr;
304-
305-
pthread_mutex_t spider_global_trx_mutex;
306-
SPIDER_TRX *spider_global_trx;
307298
#endif
308299

309300
extern pthread_mutex_t spider_mem_calc_mutex;
@@ -6090,10 +6081,6 @@ int spider_db_done(
60906081
do_delete_thd = TRUE;
60916082
}
60926083

6093-
#ifndef WITHOUT_SPIDER_BG_SEARCH
6094-
spider_free_trx(spider_global_trx, TRUE);
6095-
#endif
6096-
60976084
for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; roop_count--)
60986085
{
60996086
if (spider_dbton[roop_count].deinit)
@@ -6261,9 +6248,6 @@ int spider_db_done(
62616248
pthread_mutex_destroy(&spider_mon_table_cache_mutex);
62626249
pthread_mutex_destroy(&spider_allocated_thds_mutex);
62636250
pthread_mutex_destroy(&spider_open_conn_mutex);
6264-
#ifndef WITHOUT_SPIDER_BG_SEARCH
6265-
pthread_mutex_destroy(&spider_global_trx_mutex);
6266-
#endif
62676251
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
62686252
pthread_mutex_destroy(&spider_hs_w_conn_mutex);
62696253
pthread_mutex_destroy(&spider_hs_r_conn_mutex);
@@ -6510,18 +6494,6 @@ int spider_db_init(
65106494
error_num = HA_ERR_OUT_OF_MEM;
65116495
goto error_conn_mutex_init;
65126496
}
6513-
#ifndef WITHOUT_SPIDER_BG_SEARCH
6514-
#if MYSQL_VERSION_ID < 50500
6515-
if (pthread_mutex_init(&spider_global_trx_mutex, MY_MUTEX_INIT_FAST))
6516-
#else
6517-
if (mysql_mutex_init(spd_key_mutex_global_trx,
6518-
&spider_global_trx_mutex, MY_MUTEX_INIT_FAST))
6519-
#endif
6520-
{
6521-
error_num = HA_ERR_OUT_OF_MEM;
6522-
goto error_global_trx_mutex_init;
6523-
}
6524-
#endif
65256497
#if MYSQL_VERSION_ID < 50500
65266498
if (pthread_mutex_init(&spider_open_conn_mutex, MY_MUTEX_INIT_FAST))
65276499
#else
@@ -6786,16 +6758,9 @@ int spider_db_init(
67866758
}
67876759
}
67886760

6789-
#ifndef WITHOUT_SPIDER_BG_SEARCH
6790-
if (!(spider_global_trx = spider_get_trx(NULL, FALSE, &error_num)))
6791-
goto error;
6792-
#endif
6793-
67946761
DBUG_RETURN(0);
67956762

67966763
#ifndef WITHOUT_SPIDER_BG_SEARCH
6797-
error:
6798-
roop_count = SPIDER_DBTON_SIZE;
67996764
error_init_dbton:
68006765
for (roop_count--; roop_count >= 0; roop_count--)
68016766
{
@@ -6897,10 +6862,6 @@ int spider_db_init(
68976862
#endif
68986863
pthread_mutex_destroy(&spider_open_conn_mutex);
68996864
error_open_conn_mutex_init:
6900-
#ifndef WITHOUT_SPIDER_BG_SEARCH
6901-
pthread_mutex_destroy(&spider_global_trx_mutex);
6902-
error_global_trx_mutex_init:
6903-
#endif
69046865
pthread_mutex_destroy(&spider_conn_mutex);
69056866
error_conn_mutex_init:
69066867
pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex);

0 commit comments

Comments
 (0)