MySQL 8.0.39
Source Code Documentation
Autorejoin_thread Class Reference

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_threadoperator= (const Autorejoin_thread &)=delete
 Deleted assignment operator. More...
 
Autorejoin_threadoperator= (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

THDm_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...
 

Detailed Description

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.

See also
Plugin_gcs_events_handler

Constructor & Destructor Documentation

◆ Autorejoin_thread() [1/3]

Autorejoin_thread::Autorejoin_thread ( const Autorejoin_thread )
delete

Deleted copy ctor.

◆ Autorejoin_thread() [2/3]

Autorejoin_thread::Autorejoin_thread ( const Autorejoin_thread &&  )
delete

Deleted move ctor.

◆ Autorejoin_thread() [3/3]

Autorejoin_thread::Autorejoin_thread ( )

Initializes the synchronization primitives of the thread.

◆ ~Autorejoin_thread()

Autorejoin_thread::~Autorejoin_thread ( )

The dtor for the thread will destroy the mutex and cond_var.

Member Function Documentation

◆ abort_rejoin()

bool Autorejoin_thread::abort_rejoin ( )

Aborts the thread's main loop, effectively killing the thread.

Returns
a flag indicating whether or not the auto-rejoin procedure was ongoing at the time the abort was requested.
Return values
truethe auto-rejoin was ongoing
falsethe auto-rejoin wasn't running

◆ autorejoin_thread_handle()

void Autorejoin_thread::autorejoin_thread_handle ( )
private

The thread handle, i.e.

setups and tearsdown the infrastructure for this mysql_thread.

◆ execute_rejoin_process()

void Autorejoin_thread::execute_rejoin_process ( )
private

Handles the busy-wait retry loop.

◆ init()

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().

See also
start_autorejoin

◆ is_autorejoin_ongoing()

bool Autorejoin_thread::is_autorejoin_ongoing ( )

Returns a flag indicating whether or not the auto-rejoin process is ongoing on this thread.

Returns
the state of the rejoin process.
Return values
trueif the auto-rejoin is ongoing
falseotherwise

◆ launch_thread()

void * Autorejoin_thread::launch_thread ( void *  arg)
staticprivate

The thread callback passed onto mysql_thread_create.

Parameters
[in]arga pointer to an Autorejoin_thread instance.
Returns
Does not return.

◆ operator=() [1/2]

Autorejoin_thread & Autorejoin_thread::operator= ( const Autorejoin_thread &&  )
delete

Deleted move operator.

◆ operator=() [2/2]

Autorejoin_thread & Autorejoin_thread::operator= ( const Autorejoin_thread )
delete

Deleted assignment operator.

◆ start_autorejoin()

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.

Parameters
[in]attemptsthe number of attempts we will try to rejoin.
[in]timeoutthe time to wait between each retry.
Returns
whether or not we managed to launch the auto-rejoin thread.
Return values
0the thread launched successfully
!=0 the thread couldn't be launched
See also
mysql_thread_create

Member Data Documentation

◆ m_abort

std::atomic<bool> Autorejoin_thread::m_abort
private

flag to indicate whether or not the thread is to be aborted.

◆ m_attempts

ulong Autorejoin_thread::m_attempts
private

the number of attempts for the rejoin.

◆ m_autorejoin_thd_state

thread_state Autorejoin_thread::m_autorejoin_thd_state
private

the state of the thread.

◆ m_being_terminated

bool Autorejoin_thread::m_being_terminated
private

flag that indicates that the auto-rejoin module is in the process of being terminated.

◆ m_handle

my_thread_handle Autorejoin_thread::m_handle
private

the thread handle.

◆ m_rejoin_timeout

ulonglong Autorejoin_thread::m_rejoin_timeout
private

the time to wait in seconds until the next rejoin attempt.

◆ m_run_cond

mysql_cond_t Autorejoin_thread::m_run_cond
private

the cond_var used to signal the thread.

◆ m_run_lock

mysql_mutex_t Autorejoin_thread::m_run_lock
private

the mutex for controlling access to the thread itself.

◆ m_thd

THD* Autorejoin_thread::m_thd
private

the THD handle.


The documentation for this class was generated from the following files: