MySQL 9.0.0
Source Code Documentation
Primary_election_primary_process Class Reference

Class that contains the primary election process logic for the elected primary. More...

#include <primary_election_primary_process.h>

Inheritance diagram for Primary_election_primary_process:
[legend]

Public Member Functions

 Primary_election_primary_process ()
 Class constructor for primary election process. More...
 
 ~Primary_election_primary_process () override
 Class destructor for primary election process. More...
 
int launch_primary_election_process (enum_primary_election_mode election_mode, std::string &primary_to_elect, Group_member_info_list *group_members_info)
 Launch the local process on the primary member for primary election. More...
 
bool is_election_process_running ()
 Is the election process running? More...
 
bool is_election_process_terminating ()
 Is the process already terminating? More...
 
int terminate_election_process (bool wait=true)
 Terminate the election process on shutdown. More...
 
void wait_on_election_process_termination ()
 Waits for the election thread process to finish. More...
 
int primary_election_process_handler ()
 
void set_stop_wait_timeout (ulong timeout)
 Sets the component stop timeout. More...
 
- Public Member Functions inherited from Group_event_observer
virtual ~Group_event_observer ()=0
 

Private Member Functions

int after_view_change (const std::vector< Gcs_member_identifier > &joining, const std::vector< Gcs_member_identifier > &leaving, const std::vector< Gcs_member_identifier > &group, bool is_leaving, bool *skip_election, enum_primary_election_mode *election_mode, std::string &suggested_primary) override
 Executed after view install and before primary election. More...
 
int after_primary_election (std::string primary_uuid, enum_primary_election_primary_change_status primary_change_status, enum_primary_election_mode election_mode, int error) override
 Executed after primary election. More...
 
int before_message_handling (const Plugin_gcs_message &message, const std::string &message_origin, bool *skip_message) override
 Executed before the message is processed. More...
 
bool signal_read_mode_ready ()
 Signal that the read mode is ready on this member. More...
 

Private Attributes

std::shared_ptr< Continuationapplier_checkpoint_condition
 Continuation object to wait on the applier queue consumption. More...
 
thread_state election_process_thd_state
 The election thread status. More...
 
bool election_process_aborted
 Is the process aborted. More...
 
bool primary_ready
 
bool group_in_read_mode
 Are all group members in read mode. More...
 
bool waiting_on_queue_applied_message
 Waiting for old primary transaction execution. More...
 
bool election_process_ending
 Are the main stages of the election process finished. More...
 
enum_primary_election_mode election_mode
 The election invocation context. More...
 
std::string primary_uuid
 The primary to be elected. More...
 
ulong number_of_know_members
 The number of known members when the election started. More...
 
std::list< std::string > known_members_addresses
 The members known for the current action. More...
 
Plugin_stage_monitor_handlerstage_handler
 The stage handler for progress reporting. More...
 
ulong stop_wait_timeout
 
mysql_mutex_t election_lock
 The thread run lock. More...
 
mysql_cond_t election_cond
 The thread run condition. More...
 
my_thread_handle primary_election_pthd
 The thread handle. More...
 

Detailed Description

Class that contains the primary election process logic for the elected primary.

Constructor & Destructor Documentation

◆ Primary_election_primary_process()

Primary_election_primary_process::Primary_election_primary_process ( )

Class constructor for primary election process.

◆ ~Primary_election_primary_process()

Primary_election_primary_process::~Primary_election_primary_process ( )
override

Class destructor for primary election process.

Member Function Documentation

◆ after_primary_election()

int Primary_election_primary_process::after_primary_election ( std::string  primary_uuid,
enum_primary_election_primary_change_status  primary_change_status,
enum_primary_election_mode  election_mode,
int  error 
)
overrideprivatevirtual

Executed after primary election.

Parameters
primary_uuidthe elected primary
primary_change_statusif the primary changed after the election
election_modewhat was the election mode
errorif there was and error on the process

Implements Group_event_observer.

◆ after_view_change()

int Primary_election_primary_process::after_view_change ( const std::vector< Gcs_member_identifier > &  joining,
const std::vector< Gcs_member_identifier > &  leaving,
const std::vector< Gcs_member_identifier > &  group,
bool  is_leaving,
bool *  skip_election,
enum_primary_election_mode election_mode,
std::string &  suggested_primary 
)
overrideprivatevirtual

Executed after view install and before primary election.

Parameters
joiningmembers joining the group
leavingmembers leaving the group
groupmembers in the group
is_leavingis the member leaving
[out]skip_electionskip primary election on view
[out]election_modeelection mode
[out]suggested_primarywhat should be the next primary to elect

Implements Group_event_observer.

◆ before_message_handling()

int Primary_election_primary_process::before_message_handling ( const Plugin_gcs_message message,
const std::string &  message_origin,
bool *  skip_message 
)
overrideprivatevirtual

Executed before the message is processed.

Parameters
messageThe GCS message
message_originThe member that sent this message (address)
[out]skip_messageskip message handling if true

Implements Group_event_observer.

◆ is_election_process_running()

bool Primary_election_primary_process::is_election_process_running ( )

Is the election process running?

Returns
election_process_running

◆ is_election_process_terminating()

bool Primary_election_primary_process::is_election_process_terminating ( )

Is the process already terminating?

Returns
election_process_ending

◆ launch_primary_election_process()

int Primary_election_primary_process::launch_primary_election_process ( enum_primary_election_mode  election_mode,
std::string &  primary_to_elect,
Group_member_info_list group_members_info 
)

Launch the local process on the primary member for primary election.

Parameters
election_modethe context on which election is occurring
primary_to_electthe uuid of the primary to elect
group_members_infothe member info about group members
Returns
0 in case of success, or 1 otherwise

◆ primary_election_process_handler()

int Primary_election_primary_process::primary_election_process_handler ( )

Wait for own message so we unset the read mode when the certification packet was already queued

Note that we also send a message from us so the decision is always in a group logical moment, even if only a member exists

Why wait for the receiving of this message? So we can declare the election process as stopped in all member at the same logical moment. This is important for group configuration actions that can't start in parallel.

Note however that this packet is going to be applied asynchronously and disable certification so configuration actions should be aware of that

◆ set_stop_wait_timeout()

void Primary_election_primary_process::set_stop_wait_timeout ( ulong  timeout)

Sets the component stop timeout.

Parameters
[in]timeoutthe timeout

◆ signal_read_mode_ready()

bool Primary_election_primary_process::signal_read_mode_ready ( )
private

Signal that the read mode is ready on this member.

Returns
false in case of success, or true otherwise

◆ terminate_election_process()

int Primary_election_primary_process::terminate_election_process ( bool  wait = true)

Terminate the election process on shutdown.

Parameters
waitshould it wait for the process to finish (default true).

◆ wait_on_election_process_termination()

void Primary_election_primary_process::wait_on_election_process_termination ( )

Waits for the election thread process to finish.

Member Data Documentation

◆ applier_checkpoint_condition

std::shared_ptr<Continuation> Primary_election_primary_process::applier_checkpoint_condition
private

Continuation object to wait on the applier queue consumption.

◆ election_cond

mysql_cond_t Primary_election_primary_process::election_cond
private

The thread run condition.

◆ election_lock

mysql_mutex_t Primary_election_primary_process::election_lock
private

The thread run lock.

◆ election_mode

enum_primary_election_mode Primary_election_primary_process::election_mode
private

The election invocation context.

◆ election_process_aborted

bool Primary_election_primary_process::election_process_aborted
private

Is the process aborted.

◆ election_process_ending

bool Primary_election_primary_process::election_process_ending
private

Are the main stages of the election process finished.

◆ election_process_thd_state

thread_state Primary_election_primary_process::election_process_thd_state
private

The election thread status.

◆ group_in_read_mode

bool Primary_election_primary_process::group_in_read_mode
private

Are all group members in read mode.

◆ known_members_addresses

std::list<std::string> Primary_election_primary_process::known_members_addresses
private

The members known for the current action.

◆ number_of_know_members

ulong Primary_election_primary_process::number_of_know_members
private

The number of known members when the election started.

◆ primary_election_pthd

my_thread_handle Primary_election_primary_process::primary_election_pthd
private

The thread handle.

◆ primary_ready

bool Primary_election_primary_process::primary_ready
private

◆ primary_uuid

std::string Primary_election_primary_process::primary_uuid
private

The primary to be elected.

◆ stage_handler

Plugin_stage_monitor_handler* Primary_election_primary_process::stage_handler
private

The stage handler for progress reporting.

◆ stop_wait_timeout

ulong Primary_election_primary_process::stop_wait_timeout
private

◆ waiting_on_queue_applied_message

bool Primary_election_primary_process::waiting_on_queue_applied_message
private

Waiting for old primary transaction execution.


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