MXS-2178 Reduce accessbility of workarounds
Some rearrangements to ensure that what should be private can be kept private. - WatchdogNotifier made a friend. - WatchdogWorkaround defined in RoutingWorker and made a friend. - mxs::WatchdogWorker defined with 'using'.
This commit is contained in:
@ -433,36 +433,61 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void set_watchdog_interval(uint64_t microseconds);
|
static void set_watchdog_interval(uint64_t microseconds);
|
||||||
|
|
||||||
|
class WatchdogWorkaround;
|
||||||
|
friend WatchdogWorkaround;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal watchdog interval.
|
* @class WatchdogWorkaround
|
||||||
*
|
*
|
||||||
* @return The interval in seconds, 0 if not enabled.
|
* RAII-class using which the systemd watchdog notification can be
|
||||||
|
* handled during synchronous worker activity that causes the epoll
|
||||||
|
* event handling to be stalled.
|
||||||
|
*
|
||||||
|
* The constructor turns on the workaround and the destructor
|
||||||
|
* turns it off.
|
||||||
*/
|
*/
|
||||||
static uint32_t get_internal_watchdog_interval()
|
class WatchdogWorkaround
|
||||||
{
|
{
|
||||||
return s_watchdog_interval.secs();
|
WatchdogWorkaround(const WatchdogWorkaround&);
|
||||||
}
|
WatchdogWorkaround& operator=(const WatchdogWorkaround&);
|
||||||
|
|
||||||
// TODO: Public now ONLY so that it can be used in the workaround for the
|
public:
|
||||||
// TODO "long max[admin|ctrl] operations may trigger the watchdog" problem.
|
/**
|
||||||
void check_systemd_watchdog();
|
* Turns on the watchdog workaround for a specific worker.
|
||||||
|
*
|
||||||
|
* @param pWorker The worker for which the systemd notification
|
||||||
|
* should be arranged. Need not be the calling worker.
|
||||||
|
*/
|
||||||
|
WatchdogWorkaround(RoutingWorker* pWorker)
|
||||||
|
: m_pWorker(pWorker)
|
||||||
|
{
|
||||||
|
mxb_assert(pWorker);
|
||||||
|
m_pWorker->start_watchdog_workaround();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn on the watchdog workaround for this worker.
|
* Turns on the watchdog workaround for the calling worker.
|
||||||
*
|
*/
|
||||||
* @see mxs::WatchdogWorkaround
|
WatchdogWorkaround()
|
||||||
*/
|
: WatchdogWorkaround(RoutingWorker::get_current())
|
||||||
void start_watchdog_workaround();
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn off the watchdog workaround for this worker.
|
* Turns off the watchdog workaround.
|
||||||
*
|
*/
|
||||||
* @see mxs::WatchdogWorkaround
|
~WatchdogWorkaround()
|
||||||
*/
|
{
|
||||||
void stop_watchdog_workaround();
|
m_pWorker->stop_watchdog_workaround();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
RoutingWorker* m_pWorker;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class WatchdogNotifier;
|
class WatchdogNotifier;
|
||||||
|
friend WatchdogNotifier;
|
||||||
|
|
||||||
const int m_id; /*< The id of the worker. */
|
const int m_id; /*< The id of the worker. */
|
||||||
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map
|
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map
|
||||||
@ -484,7 +509,9 @@ private:
|
|||||||
void epoll_tick(); // override
|
void epoll_tick(); // override
|
||||||
|
|
||||||
void delete_zombies();
|
void delete_zombies();
|
||||||
//void check_systemd_watchdog();
|
void check_systemd_watchdog();
|
||||||
|
void start_watchdog_workaround();
|
||||||
|
void stop_watchdog_workaround();
|
||||||
|
|
||||||
static uint32_t epoll_instance_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
static uint32_t epoll_instance_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
||||||
uint32_t handle_epoll_events(uint32_t events);
|
uint32_t handle_epoll_events(uint32_t events);
|
||||||
@ -495,54 +522,7 @@ private:
|
|||||||
WatchdogNotifier* m_pWatchdog_notifier; /*< Watchdog notifier, if systemd enabled. */
|
WatchdogNotifier* m_pWatchdog_notifier; /*< Watchdog notifier, if systemd enabled. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
using WatchdogWorkaround = RoutingWorker::WatchdogWorkaround;
|
||||||
* @class WatchdogWorkaround
|
|
||||||
*
|
|
||||||
* RAII-class using which the systemd watchdog notification can be
|
|
||||||
* handled during synchronous worker activity that causes the epoll
|
|
||||||
* event handling to be stalled.
|
|
||||||
*
|
|
||||||
* The constructor turns on the workaround and the destructor
|
|
||||||
* turns it off.
|
|
||||||
*/
|
|
||||||
class WatchdogWorkaround
|
|
||||||
{
|
|
||||||
WatchdogWorkaround(const WatchdogWorkaround&);
|
|
||||||
WatchdogWorkaround& operator=(const WatchdogWorkaround&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Turns on the watchdog workaround for a specific worker.
|
|
||||||
*
|
|
||||||
* @param pWorker The worker for which the systemd notification
|
|
||||||
* should be arranged. Need not be the calling worker.
|
|
||||||
*/
|
|
||||||
WatchdogWorkaround(RoutingWorker* pWorker)
|
|
||||||
: m_pWorker(pWorker)
|
|
||||||
{
|
|
||||||
mxb_assert(pWorker);
|
|
||||||
m_pWorker->start_watchdog_workaround();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns on the watchdog workaround for the calling worker.
|
|
||||||
*/
|
|
||||||
WatchdogWorkaround()
|
|
||||||
: WatchdogWorkaround(RoutingWorker::get_current())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns off the watchdog workaround.
|
|
||||||
*/
|
|
||||||
~WatchdogWorkaround()
|
|
||||||
{
|
|
||||||
m_pWorker->stop_watchdog_workaround();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
RoutingWorker* m_pWorker;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Data local to a routing worker
|
// Data local to a routing worker
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -183,7 +183,7 @@ public:
|
|||||||
, m_terminate(false)
|
, m_terminate(false)
|
||||||
{
|
{
|
||||||
m_thread = std::thread([this] {
|
m_thread = std::thread([this] {
|
||||||
uint32_t interval = mxs::RoutingWorker::get_internal_watchdog_interval();
|
uint32_t interval = mxs::RoutingWorker::s_watchdog_interval.secs();
|
||||||
timespec timeout = { interval, 0 };
|
timespec timeout = { interval, 0 };
|
||||||
|
|
||||||
while (!mxb::atomic::load(&m_terminate, mxb::atomic::RELAXED))
|
while (!mxb::atomic::load(&m_terminate, mxb::atomic::RELAXED))
|
||||||
|
Reference in New Issue
Block a user