mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
MDEV-32363 Add interface to set node isolation mode in provider
This commit is contained in:
@ -100,7 +100,29 @@ namespace wsrep_impl
|
||||
<< service_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Fn> Fn resolve_function(void* dlh, const char* symbol)
|
||||
{
|
||||
union
|
||||
{
|
||||
Fn fun;
|
||||
void* obj;
|
||||
} alias;
|
||||
(void)dlerror();
|
||||
alias.obj = dlsym(dlh, symbol);
|
||||
if (alias.obj)
|
||||
{
|
||||
wsrep::log_info() << "Resolved symbol '" << symbol << "'";
|
||||
return alias.fun;
|
||||
}
|
||||
else
|
||||
{
|
||||
wsrep::log_info()
|
||||
<< "Symbol '" << symbol << "' not found from provider";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
} // namespace wsrep_impl
|
||||
|
||||
#endif // WSREP_SERVICE_HELPERS_HPP
|
||||
|
||||
|
@ -29,12 +29,13 @@
|
||||
#include "wsrep/tls_service.hpp"
|
||||
#include "wsrep/allowlist_service.hpp"
|
||||
|
||||
#include "service_helpers.hpp"
|
||||
#include "thread_service_v1.hpp"
|
||||
#include "tls_service_v1.hpp"
|
||||
#include "allowlist_service_v1.hpp"
|
||||
#include "event_service_v1.hpp"
|
||||
#include "v26/wsrep_api.h"
|
||||
|
||||
#include "v26/wsrep_node_isolation.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <cassert>
|
||||
@ -671,6 +672,8 @@ namespace
|
||||
{
|
||||
wsrep::event_service_v1_deinit(dlh);
|
||||
}
|
||||
|
||||
wsrep_node_isolation_mode_set_fn_v1 node_isolation_mode_set;
|
||||
}
|
||||
|
||||
|
||||
@ -714,6 +717,10 @@ void wsrep::wsrep_provider_v26::init_services(
|
||||
services_enabled_.event_service = services.event_service;
|
||||
}
|
||||
}
|
||||
|
||||
node_isolation_mode_set
|
||||
= wsrep_impl::resolve_function<wsrep_node_isolation_mode_set_fn_v1>(
|
||||
wsrep_->dlh, WSREP_NODE_ISOLATION_MODE_SET_V1);
|
||||
}
|
||||
|
||||
void wsrep::wsrep_provider_v26::deinit_services()
|
||||
@ -726,6 +733,7 @@ void wsrep::wsrep_provider_v26::deinit_services()
|
||||
deinit_thread_service(wsrep_->dlh);
|
||||
if (services_enabled_.allowlist_service)
|
||||
deinit_allowlist_service(wsrep_->dlh);
|
||||
node_isolation_mode_set = nullptr;
|
||||
}
|
||||
|
||||
wsrep::wsrep_provider_v26::wsrep_provider_v26(
|
||||
@ -1162,6 +1170,40 @@ wsrep::wsrep_provider_v26::options(const std::string& opts)
|
||||
return map_return_value(wsrep_->options_set(wsrep_, opts.c_str()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set node isolation mode in the provider. This function may be called from
|
||||
* signal handler, so make sure that only 'safe' system calls and library
|
||||
* functions are used. See
|
||||
* https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html
|
||||
*/
|
||||
enum wsrep::provider::status
|
||||
wsrep::wsrep_provider_v26::set_node_isolation(node_isolation mode)
|
||||
{
|
||||
if (not node_isolation_mode_set)
|
||||
{
|
||||
return error_not_implemented;
|
||||
}
|
||||
|
||||
enum wsrep_node_isolation_mode ws_mode = WSREP_NODE_ISOLATION_NOT_ISOLATED;
|
||||
switch (mode)
|
||||
{
|
||||
case node_isolation::not_isolated:
|
||||
ws_mode = WSREP_NODE_ISOLATION_NOT_ISOLATED;
|
||||
break;
|
||||
case node_isolation::isolated:
|
||||
ws_mode = WSREP_NODE_ISOLATION_ISOLATED;
|
||||
break;
|
||||
case node_isolation::force_disconnect:
|
||||
ws_mode = WSREP_NODE_ISOLATION_FORCE_DISCONNECT;
|
||||
break;
|
||||
}
|
||||
if ((*node_isolation_mode_set)(ws_mode) != WSREP_NODE_ISOLATION_SUCCESS)
|
||||
{
|
||||
return error_warning;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string wsrep::wsrep_provider_v26::name() const
|
||||
{
|
||||
return (wsrep_->provider_name ? wsrep_->provider_name : "unknown");
|
||||
|
@ -100,6 +100,7 @@ namespace wsrep
|
||||
void reset_status() WSREP_OVERRIDE;
|
||||
std::string options() const WSREP_OVERRIDE;
|
||||
enum wsrep::provider::status options(const std::string&) WSREP_OVERRIDE;
|
||||
enum status set_node_isolation(enum node_isolation mode) WSREP_OVERRIDE;
|
||||
std::string name() const WSREP_OVERRIDE;
|
||||
std::string version() const WSREP_OVERRIDE;
|
||||
std::string vendor() const WSREP_OVERRIDE;
|
||||
|
Reference in New Issue
Block a user