Skip to content

Commit 32e821e

Browse files
lkotulabjornmu
authored andcommitted
Bug#22908760 - MYSQLX UNINSTALL PLUGIN HANGS WHEN PLUGIN START FUNCTION FAILS
Description: If mysqlx will fail in entry point, the exit point of plugin will fail because of missing invalid server state or not existing thread Solution: At failure set correct server state Reviewed-by: Andrzej Religa <[email protected]> Reviewed-by: Rafal Szwarc <[email protected]> RB: 12085 (cherry picked from commit 1969b3bca7e3a55dc11d078c0489ed000725e45a)
1 parent 891707b commit 32e821e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

rapid/plugin/x/src/xpl_server.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ xpl::Server::Server(my_socket tcp_socket, boost::shared_ptr<ngs::Scheduler_dynam
126126
m_wscheduler(wscheduler),
127127
m_server(tcp_socket, wscheduler, this, config)
128128
{
129+
m_acceptor_thread.thread = 0;
129130
}
130131

131132

@@ -280,6 +281,7 @@ int xpl::Server::main(MYSQL_PLUGIN p)
280281
my_socket tcp_socket = ngs::Connection_vio::create_and_bind_socket(Plugin_system_variables::xport);
281282

282283
instance_rwl.wlock();
284+
283285
exiting = false;
284286
instance = new Server(tcp_socket, thd_scheduler, boost::make_shared<ngs::Protocol_config>());
285287

@@ -304,6 +306,8 @@ int xpl::Server::main(MYSQL_PLUGIN p)
304306
}
305307
catch(const std::exception &e)
306308
{
309+
if (instance)
310+
instance->server().start_failed();
307311
instance_rwl.unlock();
308312
my_plugin_log_message(&xpl::plugin_handle, MY_ERROR_LEVEL, "Startup failed with error \"%s\"", e.what());
309313
return 1;
@@ -327,10 +331,13 @@ int xpl::Server::exit(MYSQL_PLUGIN p)
327331
// successful
328332
instance->server().stop();
329333

330-
void *ret;
331-
log_info("Waiting for acceptor thread to finish...");
332-
ngs::thread_join(&instance->m_acceptor_thread, &ret);
333-
log_info("Acceptor thread finished");
334+
if (0 != instance->m_acceptor_thread.thread)
335+
{
336+
void *ret;
337+
log_info("Waiting for acceptor thread to finish...");
338+
ngs::thread_join(&instance->m_acceptor_thread, &ret);
339+
log_info("Acceptor thread finished");
340+
}
334341

335342
xpl::Plugin_system_variables::clean_callbacks();
336343

0 commit comments

Comments
 (0)