summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorJacob Mathew <jacob.mathew@mariadb.com>2018-04-23 22:00:27 -0700
committerJacob Mathew <jacob.mathew@mariadb.com>2018-04-23 22:00:27 -0700
commit6ee6933a374e3210ae64de8e6dc36817b8329084 (patch)
tree60526677094e876fa6b56f7d9c2d8c249db97a81 /storage
parent461de7edeaef80693e38969a4d7d3f5ae9bb5e63 (diff)
downloadmariadb-git-6ee6933a374e3210ae64de8e6dc36817b8329084.tar.gz
MDEV-15712: If remote server used by Spider table is unavailable, some operations hang for a long timebb-10.3-MDEV-15712
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.
Diffstat (limited to 'storage')
-rw-r--r--storage/spider/spd_db_conn.cc5
-rw-r--r--storage/spider/spd_db_mysql.cc21
-rw-r--r--storage/spider/spd_include.h3
3 files changed, 27 insertions, 2 deletions
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 3c1c0885617..83de99e0d2f 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -121,7 +121,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 6ff2e25bc27..21bbaaea2c9 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -11139,6 +11139,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);
@@ -11146,6 +11147,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 (
@@ -11167,6 +11169,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);
@@ -11175,6 +11178,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);
@@ -11190,11 +11194,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);
@@ -11210,6 +11216,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);
@@ -11218,11 +11225,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(),
@@ -11231,6 +11240,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);
@@ -11278,6 +11288,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 (
@@ -11299,6 +11310,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);
@@ -11307,6 +11319,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);
@@ -11322,11 +11335,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);
@@ -11342,6 +11357,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);
@@ -11350,6 +11366,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)))
@@ -11357,6 +11374,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);
@@ -11413,6 +11431,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 ca32facfa5d..bede60412e2 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -526,6 +526,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;