MySQL 8.4.2
Source Code Documentation
|
Represents and encapsulates the logic responsible for handling the auto-rejoin process within Group Replication. More...
#include <autorejoin.h>
Public Member Functions | |
Autorejoin_thread (const Autorejoin_thread &)=delete | |
Deleted copy ctor. More... | |
Autorejoin_thread (const Autorejoin_thread &&)=delete | |
Deleted move ctor. More... | |
Autorejoin_thread & | operator= (const Autorejoin_thread &)=delete |
Deleted assignment operator. More... | |
Autorejoin_thread & | operator= (const Autorejoin_thread &&)=delete |
Deleted move operator. More... | |
Autorejoin_thread () | |
Initializes the synchronization primitives of the thread. More... | |
~Autorejoin_thread () | |
The dtor for the thread will destroy the mutex and cond_var. More... | |
void | init () |
Initializes the auto-rejoin module with a clean slate, i.e. More... | |
bool | abort_rejoin () |
Aborts the thread's main loop, effectively killing the thread. More... | |
int | start_autorejoin (uint attempts, ulonglong timeout) |
Starts the process of auto-rejoin, launches the thread that will call attempt_rejoin() until it succeeds or until it reaches a given amount of maximum retries, waiting on a conditional variable each iteration with a given timeout. More... | |
bool | is_autorejoin_ongoing () |
Returns a flag indicating whether or not the auto-rejoin process is ongoing on this thread. More... | |
Private Member Functions | |
void | autorejoin_thread_handle () |
The thread handle, i.e. More... | |
void | execute_rejoin_process () |
Handles the busy-wait retry loop. More... | |
Static Private Member Functions | |
static void * | launch_thread (void *arg) |
The thread callback passed onto mysql_thread_create. More... | |
Private Attributes | |
THD * | m_thd |
the THD handle. More... | |
thread_state | m_autorejoin_thd_state |
the state of the thread. More... | |
my_thread_handle | m_handle |
the thread handle. More... | |
mysql_mutex_t | m_run_lock |
the mutex for controlling access to the thread itself. More... | |
mysql_cond_t | m_run_cond |
the cond_var used to signal the thread. More... | |
std::atomic< bool > | m_abort |
flag to indicate whether or not the thread is to be aborted. More... | |
bool | m_being_terminated |
flag that indicates that the auto-rejoin module is in the process of being terminated. More... | |
ulong | m_attempts |
the number of attempts for the rejoin. More... | |
ulonglong | m_rejoin_timeout |
the time to wait in seconds until the next rejoin attempt. More... | |
Represents and encapsulates the logic responsible for handling the auto-rejoin process within Group Replication.
The auto-rejoin process kicks in one of two possible situations: either the member was expelled from the group or the member lost contact to a majority of the group. The auto-rejoin feature must also be explicitly enabled by setting the group_replication_autorejoin_tries sysvar to a value greater than 0.
This thread will do a busy-wait loop for group_replication_autorejoin_tries number of attempts, waiting 5 minutes between each attempt (this wait is achieved via a timed wait on a conditional variable).
We execute the auto-rejoin process in its own thead because the join operation of the GCS layer is asynchronous. We cannot actually block while waiting for a confirmation if the server managed to join the group or not. As such, we wait on a callback invoked by an entity that is registered as a GCS event listener.
|
delete |
Deleted copy ctor.
|
delete |
Deleted move ctor.
Autorejoin_thread::Autorejoin_thread | ( | ) |
Initializes the synchronization primitives of the thread.
Autorejoin_thread::~Autorejoin_thread | ( | ) |
The dtor for the thread will destroy the mutex and cond_var.
bool Autorejoin_thread::abort_rejoin | ( | ) |
Aborts the thread's main loop, effectively killing the thread.
true | the auto-rejoin was ongoing |
false | the auto-rejoin wasn't running |
|
private |
The thread handle, i.e.
setups and tearsdown the infrastructure for this mysql_thread.
|
private |
Handles the busy-wait retry loop.
void Autorejoin_thread::init | ( | ) |
Initializes the auto-rejoin module with a clean slate, i.e.
it resets any state/flags that are checked in start_autorejoin().
bool Autorejoin_thread::is_autorejoin_ongoing | ( | ) |
Returns a flag indicating whether or not the auto-rejoin process is ongoing on this thread.
true | if the auto-rejoin is ongoing |
false | otherwise |
|
staticprivate |
The thread callback passed onto mysql_thread_create.
[in] | arg | a pointer to an Autorejoin_thread instance. |
|
delete |
Deleted move operator.
|
delete |
Deleted assignment operator.
int Autorejoin_thread::start_autorejoin | ( | uint | attempts, |
ulonglong | timeout | ||
) |
Starts the process of auto-rejoin, launches the thread that will call attempt_rejoin() until it succeeds or until it reaches a given amount of maximum retries, waiting on a conditional variable each iteration with a given timeout.
An auto-rejoin can only start if it isn't already running or if the auto-rejoin module is not in the process of being terminated.
[in] | attempts | the number of attempts we will try to rejoin. |
[in] | timeout | the time to wait between each retry. |
0 | the thread launched successfully |
!= | 0 the thread couldn't be launched |
|
private |
flag to indicate whether or not the thread is to be aborted.
|
private |
the number of attempts for the rejoin.
|
private |
the state of the thread.
|
private |
flag that indicates that the auto-rejoin module is in the process of being terminated.
|
private |
the thread handle.
|
private |
the time to wait in seconds until the next rejoin attempt.
|
private |
the cond_var used to signal the thread.
|
private |
the mutex for controlling access to the thread itself.
|
private |
the THD handle.