diff options
author | Jacob Mathew <jacob.mathew@mariadb.com> | 2018-04-30 19:44:02 -0700 |
---|---|---|
committer | Jacob Mathew <jacob.mathew@mariadb.com> | 2018-04-30 19:44:02 -0700 |
commit | 8fdeb079b92871f1274d5f8d9c6463fd09c9161f (patch) | |
tree | 1b36a5550c95008a8360b482453242f238a6ab14 /storage | |
parent | bcc26dce3a0335662ed43ff198921d9c34d6fc14 (diff) | |
download | mariadb-git-8fdeb079b92871f1274d5f8d9c6463fd09c9161f.tar.gz |
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
Diffstat (limited to 'storage')
-rw-r--r-- | storage/spider/spd_db_conn.cc | 5 | ||||
-rw-r--r-- | storage/spider/spd_db_mysql.cc | 21 | ||||
-rw-r--r-- | storage/spider/spd_include.h | 3 |
3 files changed, 27 insertions, 2 deletions
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index b8a295b10f8..b86a4007ce1 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -119,7 +119,10 @@ int spider_db_connect( conn->net_write_timeout = spider_param_net_write_timeout(thd, share->net_write_timeouts[link_idx]); connect_retry_interval = spider_param_connect_retry_interval(thd); - connect_retry_count = spider_param_connect_retry_count(thd); + if (conn->disable_connect_retry) + connect_retry_count = 0; + else + connect_retry_count = spider_param_connect_retry_count(thd); } else { conn->connect_timeout = spider_param_connect_timeout(NULL, share->connect_timeouts[link_idx]); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 9974b6b0628..6b873ebc4cd 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -10330,6 +10330,7 @@ int spider_mysql_handler::show_table_status( ulonglong auto_increment_value = 0; DBUG_ENTER("spider_mysql_handler::show_table_status"); DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); + if (sts_mode == 1) { pthread_mutex_lock(&conn->mta_conn_mutex); @@ -10337,6 +10338,7 @@ int spider_mysql_handler::show_table_status( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; + conn->disable_connect_retry = TRUE; spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, share); if ( @@ -10358,6 +10360,7 @@ int spider_mysql_handler::show_table_status( /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10366,6 +10369,7 @@ int spider_mysql_handler::show_table_status( } if ((error_num = spider_db_set_names(spider, conn, link_idx))) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10381,11 +10385,13 @@ int spider_mysql_handler::show_table_status( -1, &spider->need_mons[link_idx]) ) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; DBUG_RETURN(spider_db_errorno(conn)); } } else { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10401,6 +10407,7 @@ int spider_mysql_handler::show_table_status( request_key.next = NULL; if (spider_param_dry_access()) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10409,11 +10416,13 @@ int spider_mysql_handler::show_table_status( } if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; if (error_num || (error_num = spider_db_errorno(conn))) DBUG_RETURN(error_num); - else { + else + { my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), @@ -10422,6 +10431,7 @@ int spider_mysql_handler::show_table_status( DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); } } + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10469,6 +10479,7 @@ int spider_mysql_handler::show_table_status( conn->need_mon = &spider->need_mons[link_idx]; conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; + conn->disable_connect_retry = TRUE; spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, share); if ( @@ -10490,6 +10501,7 @@ int spider_mysql_handler::show_table_status( /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10498,6 +10510,7 @@ int spider_mysql_handler::show_table_status( } if ((error_num = spider_db_set_names(spider, conn, link_idx))) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10513,11 +10526,13 @@ int spider_mysql_handler::show_table_status( -1, &spider->need_mons[link_idx]) ) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; DBUG_RETURN(spider_db_errorno(conn)); } } else { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10533,6 +10548,7 @@ int spider_mysql_handler::show_table_status( request_key.next = NULL; if (spider_param_dry_access()) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10541,6 +10557,7 @@ int spider_mysql_handler::show_table_status( } if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; if (error_num || (error_num = spider_db_errorno(conn))) @@ -10548,6 +10565,7 @@ int spider_mysql_handler::show_table_status( else DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); } + conn->disable_connect_retry = FALSE; conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -10604,6 +10622,7 @@ int spider_mysql_handler::show_table_status( DBUG_PRINT("info",("spider auto_increment_value=%llu", share->lgtm_tblhnd_share->auto_increment_value)); } + DBUG_RETURN(0); } diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 37d9db3ba57..f98dfc112e9 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -449,6 +449,9 @@ typedef struct st_spider_conn st_spider_conn *bulk_access_next; #endif + bool disable_connect_retry; /* TRUE if it is unnecessary to + retry to connect after a + connection error */ bool connect_error_with_message; char connect_error_msg[MYSQL_ERRMSG_SIZE]; int connect_error; |