MySQL  8.0.19
Source Code Documentation
Primary_election_handler Class Reference

#include <primary_election_invocation_handler.h>

Inheritance diagram for Primary_election_handler:
Group_transaction_listener

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 register_transaction_observer ()
 Register an observer for transactions. More...
 
void unregister_transaction_observer ()
 Un register the observer for transactions. More...
 
virtual int before_transaction_begin (my_thread_id thread_id, ulong gr_consistency_level, ulong hold_timeout, enum_rpl_channel_type channel_type)
 Executed before a transaction begins. More...
 
virtual int before_commit (my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin)
 Executed before commit. More...
 
virtual int before_rollback (my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin)
 Executed before rollback. More...
 
virtual int after_rollback (my_thread_id thread_id)
 Executed after rollback. More...
 
virtual int after_commit (my_thread_id thread_id, rpl_sidno sidno, rpl_gno gno)
 Executed after commit. More...
 
void set_stop_wait_timeout (ulong timeout)
 Sets the component stop timeout. More...
 
- Public Member Functions inherited from Group_transaction_listener
virtual ~Group_transaction_listener ()
 Class destructor. More...
 

Private Member Functions

bool pick_primary_member (std::string &primary_uuid, std::vector< Group_member_info * > *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...
 

Additional Inherited Members

- Public Types inherited from Group_transaction_listener
enum  enum_transaction_origin { GROUP_APPLIER_TRANSACTION = 0, GROUP_RECOVERY_TRANSACTION = 1, GROUP_LOCAL_TRANSACTION = 2 }
 Enum for transaction origins. 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

◆ after_commit()

int Primary_election_handler::after_commit ( my_thread_id  thread_id,
rpl_sidno  sidno,
rpl_gno  gno 
)
virtual

Executed after commit.

Parameters
thread_idthe transaction thread id
sidnothe transaction sidno
gnothe transaction gno

Implements Group_transaction_listener.

◆ after_rollback()

int Primary_election_handler::after_rollback ( my_thread_id  thread_id)
virtual

Executed after rollback.

Parameters
thread_idthe transaction thread id

Implements Group_transaction_listener.

◆ before_commit()

int Primary_election_handler::before_commit ( my_thread_id  thread_id,
Group_transaction_listener::enum_transaction_origin  origin 
)
virtual

Executed before commit.

Parameters
thread_idthe transaction thread id
originwho applied it

Implements Group_transaction_listener.

◆ before_rollback()

int Primary_election_handler::before_rollback ( my_thread_id  thread_id,
Group_transaction_listener::enum_transaction_origin  origin 
)
virtual

Executed before rollback.

Parameters
thread_idthe transaction thread id
originwho applied it

Implements Group_transaction_listener.

◆ before_transaction_begin()

int Primary_election_handler::before_transaction_begin ( my_thread_id  thread_id,
ulong  gr_consistency_level,
ulong  hold_timeout,
enum_rpl_channel_type  channel_type 
)
virtual

Executed before a transaction begins.

Parameters
thread_idthe transaction thread id
gr_consistency_levelthe current consistency level for this session
hold_timeoutthe max time to execute an action on this transaction
channel_typetype channel that receives transaction

Implements Group_transaction_listener.

◆ 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

◆ pick_primary_member()

bool Primary_election_handler::pick_primary_member ( std::string &  primary_uuid,
std::vector< Group_member_info * > *  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.

◆ register_transaction_observer()

void Primary_election_handler::register_transaction_observer ( )

Register an observer for transactions.

◆ 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

◆ unregister_transaction_observer()

void Primary_election_handler::unregister_transaction_observer ( )

Un register the observer for transactions.

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: