diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index b1df83de162..ef529470a60 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -468,6 +468,28 @@ static void spider_update_current_trx_ha_with_freed_share(SPIDER_SHARE *share) } } +/* + Given an ha_spider that is being closed, reset the queued ping info + of SPIDER_CONN of the current spider trx that has the given + ha_spider as the queued_ping_spider. +*/ +static void spider_reset_conn_queued_ping(ha_spider *spider) +{ + SPIDER_TRX *trx= spider_current_trx; + if (trx) + { + for (uint i= 0; i < trx->trx_conn_hash.records; i++) + { + SPIDER_CONN *conn= (SPIDER_CONN *) my_hash_element(&trx->trx_conn_hash, i); + if (conn->queued_ping_spider == spider) + { + conn->queued_ping= FALSE; + conn->queued_ping_spider= NULL; + } + } + } +} + int ha_spider::close() { int error_num= 0, roop_count; @@ -562,6 +584,7 @@ int ha_spider::close() result_list.tmp_sqls = NULL; } + spider_reset_conn_queued_ping(this); spider_update_current_trx_ha_with_freed_share(share); spider_free_share(share); is_clone = FALSE; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29605.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29605.result new file mode 100644 index 00000000000..15265d739dd --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29605.result @@ -0,0 +1,19 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE USER spider@localhost IDENTIFIED BY 'pwd'; +GRANT ALL ON test.* TO spider@localhost; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'spider', password 'pwd'); +SET autocommit=0; +set @old_init_connect=@@global.init_connect; +set global init_connect="dummy"; +CREATE TABLE t ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"' AS SELECT 1; +Got one of the listed errors +set global init_connect=@old_init_connect; +drop server srv; +drop user spider@localhost; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29605.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29605.test new file mode 100644 index 00000000000..bb751c73f9b --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29605.test @@ -0,0 +1,25 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +set spider_same_server_link= 1; +CREATE USER spider@localhost IDENTIFIED BY 'pwd'; +GRANT ALL ON test.* TO spider@localhost; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'spider', password 'pwd'); +SET autocommit=0; +set @old_init_connect=@@global.init_connect; +set global init_connect="dummy"; +--error ER_NET_ERROR_ON_WRITE,12701 +CREATE TABLE t ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"' AS SELECT 1; +set global init_connect=@old_init_connect; +drop server srv; +drop user spider@localhost; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index aa91a6963a4..63d29e69de4 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2100,6 +2100,10 @@ int spider_db_mbase::exec_query( general_log_write(current_thd, COM_QUERY, tmp_query_str.ptr(), tmp_query_str.length()); } + /* There should be a live connection to the data node */ + DBUG_ASSERT(db_conn); + if (!db_conn) + DBUG_RETURN(HA_ERR_INTERNAL_ERROR); if (!spider_param_dry_access()) { error_num = mysql_real_query(db_conn, query, length);