Skip to content

Commit 8fdeb07

Browse files
author
Jacob Mathew
committed
MDEV-15712: If remote server used by Spider table is unavailable, some operations hang for a long time
When an attempt to connect to the remote server fails, Spider retries to connect to the remote server 1000 times or until the connection attempt succeeds. This is perceived as a hang if the remote server remains unavailable. I have introduced changes in Spider's table status handler to fix this problem. Author: Jacob Mathew. Reviewer: Kentoku Shiba. Cherry-Picked: Commit 6ee6933 on branch bb-10.3-MDEV-15712
1 parent bcc26dc commit 8fdeb07

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

storage/spider/spd_db_conn.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ int spider_db_connect(
119119
conn->net_write_timeout = spider_param_net_write_timeout(thd,
120120
share->net_write_timeouts[link_idx]);
121121
connect_retry_interval = spider_param_connect_retry_interval(thd);
122-
connect_retry_count = spider_param_connect_retry_count(thd);
122+
if (conn->disable_connect_retry)
123+
connect_retry_count = 0;
124+
else
125+
connect_retry_count = spider_param_connect_retry_count(thd);
123126
} else {
124127
conn->connect_timeout = spider_param_connect_timeout(NULL,
125128
share->connect_timeouts[link_idx]);

storage/spider/spd_db_mysql.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10330,13 +10330,15 @@ int spider_mysql_handler::show_table_status(
1033010330
ulonglong auto_increment_value = 0;
1033110331
DBUG_ENTER("spider_mysql_handler::show_table_status");
1033210332
DBUG_PRINT("info",("spider sts_mode=%d", sts_mode));
10333+
1033310334
if (sts_mode == 1)
1033410335
{
1033510336
pthread_mutex_lock(&conn->mta_conn_mutex);
1033610337
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
1033710338
conn->need_mon = &spider->need_mons[link_idx];
1033810339
conn->mta_conn_mutex_lock_already = TRUE;
1033910340
conn->mta_conn_mutex_unlock_later = TRUE;
10341+
conn->disable_connect_retry = TRUE;
1034010342
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
1034110343
share);
1034210344
if (
@@ -10358,6 +10360,7 @@ int spider_mysql_handler::show_table_status(
1035810360
/* retry */
1035910361
if ((error_num = spider_db_ping(spider, conn, link_idx)))
1036010362
{
10363+
conn->disable_connect_retry = FALSE;
1036110364
conn->mta_conn_mutex_lock_already = FALSE;
1036210365
conn->mta_conn_mutex_unlock_later = FALSE;
1036310366
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10366,6 +10369,7 @@ int spider_mysql_handler::show_table_status(
1036610369
}
1036710370
if ((error_num = spider_db_set_names(spider, conn, link_idx)))
1036810371
{
10372+
conn->disable_connect_retry = FALSE;
1036910373
conn->mta_conn_mutex_lock_already = FALSE;
1037010374
conn->mta_conn_mutex_unlock_later = FALSE;
1037110375
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10381,11 +10385,13 @@ int spider_mysql_handler::show_table_status(
1038110385
-1,
1038210386
&spider->need_mons[link_idx])
1038310387
) {
10388+
conn->disable_connect_retry = FALSE;
1038410389
conn->mta_conn_mutex_lock_already = FALSE;
1038510390
conn->mta_conn_mutex_unlock_later = FALSE;
1038610391
DBUG_RETURN(spider_db_errorno(conn));
1038710392
}
1038810393
} else {
10394+
conn->disable_connect_retry = FALSE;
1038910395
conn->mta_conn_mutex_lock_already = FALSE;
1039010396
conn->mta_conn_mutex_unlock_later = FALSE;
1039110397
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10401,6 +10407,7 @@ int spider_mysql_handler::show_table_status(
1040110407
request_key.next = NULL;
1040210408
if (spider_param_dry_access())
1040310409
{
10410+
conn->disable_connect_retry = FALSE;
1040410411
conn->mta_conn_mutex_lock_already = FALSE;
1040510412
conn->mta_conn_mutex_unlock_later = FALSE;
1040610413
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10409,11 +10416,13 @@ int spider_mysql_handler::show_table_status(
1040910416
}
1041010417
if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
1041110418
{
10419+
conn->disable_connect_retry = FALSE;
1041210420
conn->mta_conn_mutex_lock_already = FALSE;
1041310421
conn->mta_conn_mutex_unlock_later = FALSE;
1041410422
if (error_num || (error_num = spider_db_errorno(conn)))
1041510423
DBUG_RETURN(error_num);
10416-
else {
10424+
else
10425+
{
1041710426
my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
1041810427
ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
1041910428
mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
@@ -10422,6 +10431,7 @@ int spider_mysql_handler::show_table_status(
1042210431
DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM);
1042310432
}
1042410433
}
10434+
conn->disable_connect_retry = FALSE;
1042510435
conn->mta_conn_mutex_lock_already = FALSE;
1042610436
conn->mta_conn_mutex_unlock_later = FALSE;
1042710437
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10469,6 +10479,7 @@ int spider_mysql_handler::show_table_status(
1046910479
conn->need_mon = &spider->need_mons[link_idx];
1047010480
conn->mta_conn_mutex_lock_already = TRUE;
1047110481
conn->mta_conn_mutex_unlock_later = TRUE;
10482+
conn->disable_connect_retry = TRUE;
1047210483
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
1047310484
share);
1047410485
if (
@@ -10490,6 +10501,7 @@ int spider_mysql_handler::show_table_status(
1049010501
/* retry */
1049110502
if ((error_num = spider_db_ping(spider, conn, link_idx)))
1049210503
{
10504+
conn->disable_connect_retry = FALSE;
1049310505
conn->mta_conn_mutex_lock_already = FALSE;
1049410506
conn->mta_conn_mutex_unlock_later = FALSE;
1049510507
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10498,6 +10510,7 @@ int spider_mysql_handler::show_table_status(
1049810510
}
1049910511
if ((error_num = spider_db_set_names(spider, conn, link_idx)))
1050010512
{
10513+
conn->disable_connect_retry = FALSE;
1050110514
conn->mta_conn_mutex_lock_already = FALSE;
1050210515
conn->mta_conn_mutex_unlock_later = FALSE;
1050310516
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10513,11 +10526,13 @@ int spider_mysql_handler::show_table_status(
1051310526
-1,
1051410527
&spider->need_mons[link_idx])
1051510528
) {
10529+
conn->disable_connect_retry = FALSE;
1051610530
conn->mta_conn_mutex_lock_already = FALSE;
1051710531
conn->mta_conn_mutex_unlock_later = FALSE;
1051810532
DBUG_RETURN(spider_db_errorno(conn));
1051910533
}
1052010534
} else {
10535+
conn->disable_connect_retry = FALSE;
1052110536
conn->mta_conn_mutex_lock_already = FALSE;
1052210537
conn->mta_conn_mutex_unlock_later = FALSE;
1052310538
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10533,6 +10548,7 @@ int spider_mysql_handler::show_table_status(
1053310548
request_key.next = NULL;
1053410549
if (spider_param_dry_access())
1053510550
{
10551+
conn->disable_connect_retry = FALSE;
1053610552
conn->mta_conn_mutex_lock_already = FALSE;
1053710553
conn->mta_conn_mutex_unlock_later = FALSE;
1053810554
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10541,13 +10557,15 @@ int spider_mysql_handler::show_table_status(
1054110557
}
1054210558
if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
1054310559
{
10560+
conn->disable_connect_retry = FALSE;
1054410561
conn->mta_conn_mutex_lock_already = FALSE;
1054510562
conn->mta_conn_mutex_unlock_later = FALSE;
1054610563
if (error_num || (error_num = spider_db_errorno(conn)))
1054710564
DBUG_RETURN(error_num);
1054810565
else
1054910566
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
1055010567
}
10568+
conn->disable_connect_retry = FALSE;
1055110569
conn->mta_conn_mutex_lock_already = FALSE;
1055210570
conn->mta_conn_mutex_unlock_later = FALSE;
1055310571
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
@@ -10604,6 +10622,7 @@ int spider_mysql_handler::show_table_status(
1060410622
DBUG_PRINT("info",("spider auto_increment_value=%llu",
1060510623
share->lgtm_tblhnd_share->auto_increment_value));
1060610624
}
10625+
1060710626
DBUG_RETURN(0);
1060810627
}
1060910628

storage/spider/spd_include.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ typedef struct st_spider_conn
449449
st_spider_conn *bulk_access_next;
450450
#endif
451451

452+
bool disable_connect_retry; /* TRUE if it is unnecessary to
453+
retry to connect after a
454+
connection error */
452455
bool connect_error_with_message;
453456
char connect_error_msg[MYSQL_ERRMSG_SIZE];
454457
int connect_error;

0 commit comments

Comments
 (0)