Commit dde0a83f authored by Jan Lindström's avatar Jan Lindström

MDEV-17801: Galera test failure on galera_var_reject_queries

Problem was that controlling connection i.e. connection that
executed the query SET GLOBAL wsrep_reject_queries = ALL_KILL;
was also killed but server would try to send result from that
query to controlling connection resulting a assertion
mysqld: /home/jan/mysql/10.2-sst/include/mysql/psi/mysql_socket.h:738: inline_mysql_socket_send: Assertion `mysql_socket.fd != -1' failed.
as socket was closed when controlling connection was closed.

wsrep_close_client_connections()
	Do not close controlling connection and instead of
	wsrep_close_thread() we do now soft kill by THD::awake

wsrep_reject_queries_update()
	Call wsrep_close_client_connections using current thd.
parent 2b49e156
...@@ -7,7 +7,6 @@ SET GLOBAL wsrep_reject_queries = ALL; ...@@ -7,7 +7,6 @@ SET GLOBAL wsrep_reject_queries = ALL;
SELECT * FROM t1; SELECT * FROM t1;
ERROR 08S01: WSREP has not yet prepared node for application use ERROR 08S01: WSREP has not yet prepared node for application use
SET GLOBAL wsrep_reject_queries = ALL_KILL; SET GLOBAL wsrep_reject_queries = ALL_KILL;
ERROR HY000: Lost connection to MySQL server during query
connection node_1a; connection node_1a;
SELECT * FROM t1; SELECT * FROM t1;
Got one of the listed errors Got one of the listed errors
......
...@@ -18,8 +18,11 @@ SET GLOBAL wsrep_reject_queries = ALL; ...@@ -18,8 +18,11 @@ SET GLOBAL wsrep_reject_queries = ALL;
--error ER_UNKNOWN_COM_ERROR --error ER_UNKNOWN_COM_ERROR
SELECT * FROM t1; SELECT * FROM t1;
# Lost connection #
--error 2013 # Original behavior was lost connection,
# but since 10.1, we allow controlling connection to remain alive
#
--error 0,2013
SET GLOBAL wsrep_reject_queries = ALL_KILL; SET GLOBAL wsrep_reject_queries = ALL_KILL;
--connection node_1a --connection node_1a
......
...@@ -2270,7 +2270,7 @@ int wsrep_wait_committing_connections_close(int wait_time) ...@@ -2270,7 +2270,7 @@ int wsrep_wait_committing_connections_close(int wait_time)
} }
void wsrep_close_client_connections(my_bool wait_to_end) void wsrep_close_client_connections(my_bool wait_to_end, THD *except_caller_thd)
{ {
/* /*
First signal all threads that it's time to die First signal all threads that it's time to die
...@@ -2292,6 +2292,12 @@ void wsrep_close_client_connections(my_bool wait_to_end) ...@@ -2292,6 +2292,12 @@ void wsrep_close_client_connections(my_bool wait_to_end)
if (!is_client_connection(tmp)) if (!is_client_connection(tmp))
continue; continue;
if (tmp == except_caller_thd)
{
DBUG_ASSERT(is_client_connection(tmp));
continue;
}
if (is_replaying_connection(tmp)) if (is_replaying_connection(tmp))
{ {
tmp->set_killed(KILL_CONNECTION); tmp->set_killed(KILL_CONNECTION);
...@@ -2303,7 +2309,16 @@ void wsrep_close_client_connections(my_bool wait_to_end) ...@@ -2303,7 +2309,16 @@ void wsrep_close_client_connections(my_bool wait_to_end)
continue; continue;
WSREP_DEBUG("closing connection %lld", (longlong) tmp->thread_id); WSREP_DEBUG("closing connection %lld", (longlong) tmp->thread_id);
wsrep_close_thread(tmp);
/*
instead of wsrep_close_thread() we do now soft kill by THD::awake
*/
mysql_mutex_lock(&tmp->LOCK_thd_data);
tmp->awake(KILL_CONNECTION);
mysql_mutex_unlock(&tmp->LOCK_thd_data);
} }
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
...@@ -2321,7 +2336,8 @@ void wsrep_close_client_connections(my_bool wait_to_end) ...@@ -2321,7 +2336,8 @@ void wsrep_close_client_connections(my_bool wait_to_end)
#ifndef __bsdi__ // Bug in BSDI kernel #ifndef __bsdi__ // Bug in BSDI kernel
if (is_client_connection(tmp) && if (is_client_connection(tmp) &&
!abort_replicated(tmp) && !abort_replicated(tmp) &&
!is_replaying_connection(tmp)) !is_replaying_connection(tmp) &&
tmp != except_caller_thd)
{ {
WSREP_INFO("killing local connection: %lld", (longlong) tmp->thread_id); WSREP_INFO("killing local connection: %lld", (longlong) tmp->thread_id);
close_connection(tmp,0); close_connection(tmp,0);
......
...@@ -160,7 +160,6 @@ extern "C" query_id_t wsrep_thd_query_id(THD *thd); ...@@ -160,7 +160,6 @@ extern "C" query_id_t wsrep_thd_query_id(THD *thd);
extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd); extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd);
extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id); extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id);
extern void wsrep_close_client_connections(my_bool wait_to_end);
extern int wsrep_wait_committing_connections_close(int wait_time); extern int wsrep_wait_committing_connections_close(int wait_time);
extern void wsrep_close_applier(THD *thd); extern void wsrep_close_applier(THD *thd);
extern void wsrep_wait_appliers_close(THD *thd); extern void wsrep_wait_appliers_close(THD *thd);
...@@ -313,7 +312,8 @@ void thd_binlog_trx_reset(THD * thd); ...@@ -313,7 +312,8 @@ void thd_binlog_trx_reset(THD * thd);
typedef void (*wsrep_thd_processor_fun)(THD *); typedef void (*wsrep_thd_processor_fun)(THD *);
pthread_handler_t start_wsrep_THD(void *arg); pthread_handler_t start_wsrep_THD(void *arg);
int wsrep_wait_committing_connections_close(int wait_time); int wsrep_wait_committing_connections_close(int wait_time);
void wsrep_close_client_connections(my_bool wait_to_end); extern void wsrep_close_client_connections(my_bool wait_to_end,
THD *except_caller_thd = NULL);
void wsrep_close_applier(THD *thd); void wsrep_close_applier(THD *thd);
void wsrep_close_applier_threads(int count); void wsrep_close_applier_threads(int count);
void wsrep_wait_appliers_close(THD *thd); void wsrep_wait_appliers_close(THD *thd);
......
...@@ -428,7 +428,8 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type) ...@@ -428,7 +428,8 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
WSREP_INFO("Rejecting client queries due to manual setting"); WSREP_INFO("Rejecting client queries due to manual setting");
break; break;
case WSREP_REJECT_ALL_KILL: case WSREP_REJECT_ALL_KILL:
wsrep_close_client_connections(FALSE); /* close all client connections, but this one */
wsrep_close_client_connections(FALSE, thd);
WSREP_INFO("Rejecting client queries and killing connections due to manual setting"); WSREP_INFO("Rejecting client queries and killing connections due to manual setting");
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment