summaryrefslogtreecommitdiff
path: root/storage/federated
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-12-06 01:48:07 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-07 15:20:23 +0100
commit18954ff25d27252f3ce9865e636c91e0783572af (patch)
treef69ab1089475cbcb6fd74938f077cf4e2b42ef09 /storage/federated
parent354e567c2384f95126ffa1e36382c4e0c206521c (diff)
downloadmariadb-git-18954ff25d27252f3ce9865e636c91e0783572af.tar.gz
MDEV-8313 Got an error writing communication packets
Don't let network errors from mysql_close() leak into THD. * remove incorrect upstream fix ** table->in_use can be NULL, must use ha_thd() ** clear_error() may remove earlier errors, don't use it * fix the bug properly in federated and federatedx
Diffstat (limited to 'storage/federated')
-rw-r--r--storage/federated/ha_federated.cc31
1 files changed, 21 insertions, 10 deletions
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index c720213bb4f..adf4f0f4db2 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -1662,6 +1662,20 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
DBUG_RETURN(0);
}
+class Net_error_handler : public Internal_error_handler
+{
+public:
+ Net_error_handler() {}
+
+public:
+ bool handle_condition(THD *thd, uint sql_errno, const char* sqlstate,
+ MYSQL_ERROR::enum_warning_level level,
+ const char* msg, MYSQL_ERROR ** cond_hdl)
+ {
+ return sql_errno >= ER_ABORTING_CONNECTION &&
+ sql_errno <= ER_NET_WRITE_INTERRUPTED;
+ }
+};
/*
Closes a table. We call the free_share() function to free any resources
@@ -1683,18 +1697,15 @@ int ha_federated::close(void)
delete_dynamic(&results);
/* Disconnect from mysql */
+ THD *thd= ha_thd();
+ Net_error_handler err_handler;
+ if (thd)
+ thd->push_internal_handler(&err_handler);
mysql_close(mysql);
- mysql= NULL;
+ if (thd)
+ thd->pop_internal_handler();
- /*
- mysql_close() might return an error if a remote server's gone
- for some reason. If that happens while removing a table from
- the table cache, the error will be propagated to a client even
- if the original query was not issued against the FEDERATED table.
- So, don't propagate errors from mysql_close().
- */
- if (table->in_use)
- table->in_use->clear_error();
+ mysql= NULL;
DBUG_RETURN(free_share(share));
}