MySQL 9.1.0
Source Code Documentation
Primary_election_handler Class Reference

The base class to request and execute an election. More...

#include <primary_election_invocation_handler.h>

Public Member Functions

 Primary_election_handler (ulong components_stop_timeout)
 Instantiate a new election handler. More...
 
 ~Primary_election_handler ()
 Class destructor. More...
 
int request_group_primary_election (std::string primary_uuid, enum_primary_election_mode mode)
 Send a message to all members requesting an election. More...
 
int handle_primary_election_message (Single_primary_message *message, Notification_context *notification_ctx)
 Handle new received primary message of type SINGLE_PRIMARY_PRIMARY_ELECTION. More...
 
int execute_primary_election (std::string &primary_uuid, enum_primary_election_mode mode, Notification_context *notification_ctx)
 Execute the primary member selection if needed and the election algorithm invocation. More...
 
void print_gtid_info_in_log ()
 Print server executed GTID and applier retrieved GTID in logs. More...
 
bool is_an_election_running ()
 Is an election process running? More...
 
void set_election_running (bool election_running)
 Sets if the election process is running or not. More...
 
int terminate_election_process ()
 End any running election process. More...
 
void notify_election_running ()
 Notify transaction consistency manager that election is running. More...
 
void notify_election_end ()
 Notify transaction consistency manager that election ended. More...
 
void set_stop_wait_timeout (ulong timeout)
 Sets the component stop timeout. More...
 

Private Member Functions

bool pick_primary_member (std::string &primary_uuid, Group_member_info_list *all_members_info)
 Get the member to elect from all group members. More...
 
int internal_primary_election (std::string &primary_uuid, enum_primary_election_mode mode)
 Execute the standard primary election algorithm (that supports primary appointments) More...
 
int legacy_primary_election (std::string &primary_uuid)
 Execute the legacy (<8.0.12) primary election algorithm. More...
 

Private Attributes

Primary_election_primary_process primary_election_handler
 The handler to handle the election on the primary member. More...
 
Primary_election_secondary_process secondary_election_handler
 The handler to handle the election in the secondary members. More...
 
bool election_process_running
 Is an election running? More...
 
mysql_mutex_t flag_lock
 The lock for the running flag. More...
 

Detailed Description

The base class to request and execute an election.

Constructor & Destructor Documentation

◆ Primary_election_handler()

Primary_election_handler::Primary_election_handler ( ulong  components_stop_timeout)

Instantiate a new election handler.

Parameters
[in]components_stop_timeoutthe timeout when waiting on shutdown

◆ ~Primary_election_handler()

Primary_election_handler::~Primary_election_handler ( )

Class destructor.

Member Function Documentation

◆ execute_primary_election()

int Primary_election_handler::execute_primary_election ( std::string &  primary_uuid,
enum_primary_election_mode  mode,
Notification_context notification_ctx 
)

Execute the primary member selection if needed and the election algorithm invocation.

Parameters
primary_uuidthe primary member to elect
modethe election mode to use
notification_ctxthe notification object to report changes
Returns
!=0 in case of error

◆ handle_primary_election_message()

int Primary_election_handler::handle_primary_election_message ( Single_primary_message message,
Notification_context notification_ctx 
)

Handle new received primary message of type SINGLE_PRIMARY_PRIMARY_ELECTION.

Parameters
messageThe received primary message
notification_ctxthe notification object to report changes
Returns
!=0 in case of error

◆ internal_primary_election()

int Primary_election_handler::internal_primary_election ( std::string &  primary_uuid,
enum_primary_election_mode  mode 
)
private

Execute the standard primary election algorithm (that supports primary appointments)

Parameters
primary_uuidthe primary member to elect
modethe election mode to use

Wait for an old process to end

◆ is_an_election_running()

bool Primary_election_handler::is_an_election_running ( )

Is an election process running?

Returns
true if yes, false if no

◆ legacy_primary_election()

int Primary_election_handler::legacy_primary_election ( std::string &  primary_uuid)
private

Execute the legacy (<8.0.12) primary election algorithm.

Parameters
primary_uuidthe primary member to elect

◆ notify_election_end()

void Primary_election_handler::notify_election_end ( )

Notify transaction consistency manager that election ended.

◆ notify_election_running()

void Primary_election_handler::notify_election_running ( )

Notify transaction consistency manager that election is running.

◆ pick_primary_member()

bool Primary_election_handler::pick_primary_member ( std::string &  primary_uuid,
Group_member_info_list all_members_info 
)
private

Get the member to elect from all group members.

This method returns the current primary if one exists If no primary exists this method returns one of the lowest version present in the group according to a weight or uuid criteria.

Parameters
[out]primary_uuidthe primary member to elect
[in]all_members_infoThe members currently in the group
Returns
true if a primary is found, false otherwise

◆ print_gtid_info_in_log()

void Primary_election_handler::print_gtid_info_in_log ( )

Print server executed GTID and applier retrieved GTID in logs.

◆ request_group_primary_election()

int Primary_election_handler::request_group_primary_election ( std::string  primary_uuid,
enum_primary_election_mode  mode 
)

Send a message to all members requesting an election.

Parameters
primary_uuidthe primary member to elect
modethe election mode to use

◆ set_election_running()

void Primary_election_handler::set_election_running ( bool  election_running)

Sets if the election process is running or not.

Parameters
election_runningis the election running or not

◆ set_stop_wait_timeout()

void Primary_election_handler::set_stop_wait_timeout ( ulong  timeout)

Sets the component stop timeout.

Parameters
[in]timeoutthe timeout

◆ terminate_election_process()

int Primary_election_handler::terminate_election_process ( )

End any running election process.

Returns
!=0 in case of error

Member Data Documentation

◆ election_process_running

bool Primary_election_handler::election_process_running
private

Is an election running?

◆ flag_lock

mysql_mutex_t Primary_election_handler::flag_lock
private

The lock for the running flag.

◆ primary_election_handler

Primary_election_primary_process Primary_election_handler::primary_election_handler
private

The handler to handle the election on the primary member.

◆ secondary_election_handler

Primary_election_secondary_process Primary_election_handler::secondary_election_handler
private

The handler to handle the election in the secondary members.


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