MySQL 9.0.0
Source Code Documentation
Plugin_gcs_events_handler Class Reference

#include <gcs_event_handlers.h>

Inheritance diagram for Plugin_gcs_events_handler:
[legend]

Public Member Functions

 Plugin_gcs_events_handler (Applier_module_interface *applier_module, Recovery_module *recovery_module, Compatibility_module *compatibility_manager, ulong components_stop_timeout)
 Plugin_gcs_events_handler constructor. More...
 
 ~Plugin_gcs_events_handler () override
 
void on_message_received (const Gcs_message &message) const override
 This method is called whenever a message is to be delivered. More...
 
void on_view_changed (const Gcs_view &new_view, const Exchanged_data &exchanged_data) const override
 This method is called when the view is ready to be installed. More...
 
Gcs_message_dataget_exchangeable_data () const override
 This method is called when the Data Exchange is about to happen in order for the client to provide which data it wants to exchange with the group. More...
 
void on_suspicions (const std::vector< Gcs_member_identifier > &members, const std::vector< Gcs_member_identifier > &unreachable) const override
 This member function is called when the set of suspicions has changed in the underlying communication infrastructure. More...
 
void set_stop_wait_timeout (ulong timeout)
 Sets the component stop timeout. More...
 
void disable_read_mode_for_compatible_members (bool force_check=false) const
 This function disable read-only mode when member version is compatible with group. More...
 
- Public Member Functions inherited from Gcs_communication_event_listener
virtual ~Gcs_communication_event_listener ()=default
 
- Public Member Functions inherited from Gcs_control_event_listener
virtual ~Gcs_control_event_listener ()=default
 

Private Member Functions

void handle_transactional_message (const Gcs_message &message) const
 
void handle_recovery_metadata (const Gcs_message &message) const
 
void handle_transactional_with_guarantee_message (const Gcs_message &message) const
 
void handle_transaction_prepared_message (const Gcs_message &message) const
 
void handle_sync_before_execution_message (const Gcs_message &message) const
 
void handle_certifier_message (const Gcs_message &message) const
 
void handle_recovery_message (Plugin_gcs_message *message) const
 
void handle_stats_message (const Gcs_message &message) const
 
void handle_single_primary_message (Plugin_gcs_message *processed_message) const
 
void handle_group_action_message (const Gcs_message &message) const
 
bool pre_process_message (Plugin_gcs_message *plugin_message, const std::string &message_origin) const
 This method passes the message to message listeners. More...
 
int update_group_info_manager (const Gcs_view &new_view, const Exchanged_data &exchanged_data, bool is_joining, bool is_leaving) const
 
void handle_joining_members (const Gcs_view &new_view, bool is_joining, bool is_leaving) const
 
void handle_leaving_members (const Gcs_view &new_view, bool is_joining, bool is_leaving) const
 
void update_member_status (const std::vector< Gcs_member_identifier > &members, Group_member_info::Group_member_status status, Group_member_info::Group_member_status old_equal_to, Group_member_info::Group_member_status old_different_from) const
 This method updates the status of the members in the list according to the given parameters. More...
 
void handle_leader_election_if_needed (enum_primary_election_mode election_mode, std::string &suggested_primary) const
 This method handles the election of a new primary node when the plugin runs in single primary mode. More...
 
int process_local_exchanged_data (const Exchanged_data &exchanged_data, bool is_joining) const
 
bool is_member_on_vector (const std::vector< Gcs_member_identifier > &members, const Gcs_member_identifier &member_id) const
 Verifies if a certain Vector of Member Ids contains a given member id. More...
 
int check_group_compatibility (size_t number_of_members) const
 Checks the compatibility of the member with the group. More...
 
st_compatibility_types check_version_compatibility_with_group () const
 When the member is joining, cycle through all members on group and see if it is compatible with them. More...
 
int compare_member_transaction_sets () const
 Method that compares the group's aggregated GTID set against the joiner GTID set. More...
 
void collect_members_executed_sets (View_change_packet *view_packet) const
 This method takes all the group executed sets and adds those belonging to non recovering member to the view change packet. More...
 
int compare_member_option_compatibility () const
 Method that compares the member options with the value of the same option on all other members. More...
 
bool is_group_running_a_configuration_change (std::string &group_action_running_initiator, std::string &group_action_running_description) const
 Check if a member is not entering a group where an action is running. More...
 
bool is_group_running_a_primary_election () const
 Check if the group is running a primary election. More...
 
bool was_member_expelled_from_group (const Gcs_view &view) const
 This method checks if member was expelled from the group due to network failures. More...
 
void log_members_joining_message (const Gcs_view &new_view) const
 Logs member joining message to error logs from view. More...
 
void log_messages_during_member_leave (const Gcs_view &new_view) const
 Logs member leaving message to error logs from view. More...
 
void get_hosts_from_view (const std::vector< Gcs_member_identifier > &members, std::string &all_hosts, std::string &primary_host) const
 This function return all members present in vector of Gcs_member_identifier in HOST:PORT format separated by comma. More...
 
void leave_group_on_recovery_metadata_error (std::string error_message) const
 Leave group on recovering metadata error. More...
 

Private Attributes

Applier_module_interfaceapplier_module
 
Recovery_modulerecovery_module
 
std::set< Group_member_info *, Group_member_info_pointer_comparator > * temporary_states
 
Compatibility_modulecompatibility_manager
 
st_compatibility_typesjoiner_compatibility_status
 The status of this member when it joins. More...
 
ulong stop_wait_timeout
 
bool set_number_of_members_on_view_changed_to_10
 
Notification_context m_notification_ctx
 The notification context for the GCS delivery thread. More...
 

Constructor & Destructor Documentation

◆ Plugin_gcs_events_handler()

Plugin_gcs_events_handler::Plugin_gcs_events_handler ( Applier_module_interface applier_module,
Recovery_module recovery_module,
Compatibility_module compatibility_manager,
ulong  components_stop_timeout 
)

Plugin_gcs_events_handler constructor.

It receives, via the constructor, all the necessary dependencies to work.

◆ ~Plugin_gcs_events_handler()

Plugin_gcs_events_handler::~Plugin_gcs_events_handler ( )
override

Member Function Documentation

◆ check_group_compatibility()

int Plugin_gcs_events_handler::check_group_compatibility ( size_t  number_of_members) const
private

Checks the compatibility of the member with the group.

Here we check: 1) If the number of members was exceeded 2) If member version is compatible with the group 3) If the gtid_assignment_block_size is equal to the group 4) If the hash algorithm used is equal to the group 5) If the member has more known transactions than the group 6) If the member has the same configuration flags that the group has.

It checks: 1) If the number of members was exceeded 2) If member version is compatible with the group 3) If the gtid_assignment_block_size is equal to the group 4) If the hash algorithm used is equal to the group 5) If the member has more known transactions than the group

Parameters
number_of_membersthe number of members in the new view
Return values
0compatible
>0not compatible with the group

◆ check_version_compatibility_with_group()

Compatibility_type Plugin_gcs_events_handler::check_version_compatibility_with_group ( ) const
private

When the member is joining, cycle through all members on group and see if it is compatible with them.

Returns
the compatibility with the group
Return values
INCOMPATIBLE//Versions not compatible
COMPATIBLE//Versions compatible
READ_COMPATIBLE//Member can read but not write

◆ collect_members_executed_sets()

void Plugin_gcs_events_handler::collect_members_executed_sets ( View_change_packet view_packet) const
private

This method takes all the group executed sets and adds those belonging to non recovering member to the view change packet.

Parameters
[in]view_packetthe view change packet

◆ compare_member_option_compatibility()

int Plugin_gcs_events_handler::compare_member_option_compatibility ( ) const
private

Method that compares the member options with the value of the same option on all other members.

It compares: 1) GTID assignment block size 2) Write set hash algorithm

Return values
0Joiner has the same value as all other members
!=0Otherwise

◆ compare_member_transaction_sets()

int Plugin_gcs_events_handler::compare_member_transaction_sets ( ) const
private

Method that compares the group's aggregated GTID set against the joiner GTID set.

These sets contain executed and received GTIDs present in the relay log files belonging to each member plugin applier channel.

Returns
if the joiner has more GTIDs then the group.
Return values
0Joiner has less GTIDs than the group
>0Joiner has more GTIDS than the group
<0Error when processing GTID information

◆ disable_read_mode_for_compatible_members()

void Plugin_gcs_events_handler::disable_read_mode_for_compatible_members ( bool  force_check = false) const

This function disable read-only mode when member version is compatible with group.

Parameters
[in]force_checkCompatibility is mandatory re-checked

◆ get_exchangeable_data()

Gcs_message_data * Plugin_gcs_events_handler::get_exchangeable_data ( ) const
overridevirtual

This method is called when the Data Exchange is about to happen in order for the client to provide which data it wants to exchange with the group.

Returns
a reference to the exchangeable data. This is a pointer that must be deallocated by the caller, so please provide always a copy of the data to exchange.

Implements Gcs_control_event_listener.

◆ get_hosts_from_view()

void Plugin_gcs_events_handler::get_hosts_from_view ( const std::vector< Gcs_member_identifier > &  members,
std::string &  all_hosts,
std::string &  primary_host 
) const
private

This function return all members present in vector of Gcs_member_identifier in HOST:PORT format separated by comma.

Function also return PRIMARY member if any in HOST:PORT format.

Parameters
[in]membersjoining or leaving members for this view
[out]all_hostshost and port of all members from view
[out]primary_hostprimary member hosts and port of all members from view

Check in_primary_mode has been added for safety. Since primary role is in single-primary mode.

◆ handle_certifier_message()

void Plugin_gcs_events_handler::handle_certifier_message ( const Gcs_message message) const
private

◆ handle_group_action_message()

void Plugin_gcs_events_handler::handle_group_action_message ( const Gcs_message message) const
private

◆ handle_joining_members()

void Plugin_gcs_events_handler::handle_joining_members ( const Gcs_view new_view,
bool  is_joining,
bool  is_leaving 
) const
private

On the joining list there can be 3 types of members: 1) ONLINE/RECOVERING members coming from old views where this member was not present; 2) new joining members that still have their status as OFFLINE; 3) old members that were expelled and did auto-rejoin, that have their status as ERROR.

As so, for members with state OFFLINE and ERROR, their state is changed to RECOVERING after member compatibility with group is checked.

Is an election running while I'm joining?

Set the read mode if not set during start (auto-start)

On the joining member log an error when group contains more members than auto_increment_increment variable.

On the joining list there can be 3 types of members: 1) ONLINE/RECOVERING members coming from old views where this member was not present; 2) new joining members that still have their status as OFFLINE; 3) old members that were expelled and did auto-rejoin, that have their status as ERROR.

As so, for members with state OFFLINE and ERROR, their state is changed to RECOVERING after member compatibility with group is checked.

If not a joining member, all members should record on their own binlogs a marking event that identifies the frontier between the data the joining member was to receive and the data it should queue. The joining member can then wait for this event to know it was all the needed data.

This packet will also pass in the certification process at this exact frontier giving us the opportunity to gather the necessary certification information to certify the transactions that will come after this view change. If selected as a donor, this info will also be sent to the joiner.

Associated to this process, we collect and intersect the executed GTID sets of all ONLINE members so we can cut the certification info to gather and transmit to the minimum.

◆ handle_leader_election_if_needed()

void Plugin_gcs_events_handler::handle_leader_election_if_needed ( enum_primary_election_mode  election_mode,
std::string &  suggested_primary 
) const
private

This method handles the election of a new primary node when the plugin runs in single primary mode.

Parameters
election_modeelection type
suggested_primarywhat should be the next primary to elect
Note
This function unsets the super read only mode on primary node and sets it on secondary nodes

◆ handle_leaving_members()

void Plugin_gcs_events_handler::handle_leaving_members ( const Gcs_view new_view,
bool  is_joining,
bool  is_leaving 
) const
private

◆ handle_recovery_message()

void Plugin_gcs_events_handler::handle_recovery_message ( Plugin_gcs_message message) const
private

Re-check compatibility, members may leave during recovery. Disable the read mode in the server if the member is:

  • joining
  • doesn't have a higher possible incompatible version
  • We are not on Primary mode.

◆ handle_recovery_metadata()

void Plugin_gcs_events_handler::handle_recovery_metadata ( const Gcs_message message) const
private

Check if the View_ID in the received recovery metadata matches with the locally stored View_ID on the joiner. This locally stored View_ID is on which joining member joined the group.

  • View_ID matches it's JOINER: a. It means the joiner has received the metadata and it can use it to recover and come ONLINE. b. Also local copy of View_ID stored in Recovery_metadata_joiner_information can be removed. c. It also creates a copy of recovery metadata which is processed later by recovery thread. GCS thread which holds current copy of recovery metadata may delete it before recovery process it, so another copy needs to be created. d. Awake Recovery module waiting for Metadata to be received.
  • View_ID does not match it's SENDER: e. The recovery metadata broadcast was successful now local copy of recovery metadata is deleted.
  • If there is error, cleanup and member leaves the group.

◆ handle_single_primary_message()

void Plugin_gcs_events_handler::handle_single_primary_message ( Plugin_gcs_message processed_message) const
private

◆ handle_stats_message()

void Plugin_gcs_events_handler::handle_stats_message ( const Gcs_message message) const
private

◆ handle_sync_before_execution_message()

void Plugin_gcs_events_handler::handle_sync_before_execution_message ( const Gcs_message message) const
private

◆ handle_transaction_prepared_message()

void Plugin_gcs_events_handler::handle_transaction_prepared_message ( const Gcs_message message) const
private

◆ handle_transactional_message()

void Plugin_gcs_events_handler::handle_transactional_message ( const Gcs_message message) const
private

◆ handle_transactional_with_guarantee_message()

void Plugin_gcs_events_handler::handle_transactional_with_guarantee_message ( const Gcs_message message) const
private

◆ is_group_running_a_configuration_change()

bool Plugin_gcs_events_handler::is_group_running_a_configuration_change ( std::string &  group_action_running_initiator,
std::string &  group_action_running_description 
) const
private

Check if a member is not entering a group where an action is running.

If action is running provide details of action.

Parameters
[out]group_action_running_initiatorGroup action configuration initiator details
[out]group_action_running_descriptionGroup action configuration description
Return values
falseno group action is running
truea group action is running

◆ is_group_running_a_primary_election()

bool Plugin_gcs_events_handler::is_group_running_a_primary_election ( ) const
private

Check if the group is running a primary election.

Return values
falseno primary election is running
truea primary election is running

◆ is_member_on_vector()

bool Plugin_gcs_events_handler::is_member_on_vector ( const std::vector< Gcs_member_identifier > &  members,
const Gcs_member_identifier member_id 
) const
private

Verifies if a certain Vector of Member Ids contains a given member id.

Parameters
membersthe vector with members to verify
member_idthe member to check if it contained.
Returns
true if member_id occurs in members.

◆ leave_group_on_recovery_metadata_error()

void Plugin_gcs_events_handler::leave_group_on_recovery_metadata_error ( std::string  error_message) const
private

Leave group on recovering metadata error.

Parameters
[in]error_messageLog error message on member leave.

◆ log_members_joining_message()

void Plugin_gcs_events_handler::log_members_joining_message ( const Gcs_view new_view) const
private

Logs member joining message to error logs from view.

Parameters
[in]new_viewthe view delivered by the GCS

◆ log_messages_during_member_leave()

void Plugin_gcs_events_handler::log_messages_during_member_leave ( const Gcs_view new_view) const
private

Logs member leaving message to error logs from view.

Parameters
[in]new_viewthe view delivered by the GCS

◆ on_message_received()

void Plugin_gcs_events_handler::on_message_received ( const Gcs_message message) const
overridevirtual

This method is called whenever a message is to be delivered.

Parameters
[in]messageThe received message. This is currently a reference to avoid the existence of dangling pointers.

From this point messages are sent to message listeners and may be skipped Messages above are directly processed and/or for performance we do not want to add that extra weight.

Implements Gcs_communication_event_listener.

◆ on_suspicions()

void Plugin_gcs_events_handler::on_suspicions ( const std::vector< Gcs_member_identifier > &  members,
const std::vector< Gcs_member_identifier > &  unreachable 
) const
overridevirtual

This member function is called when the set of suspicions has changed in the underlying communication infrastructure.

Parameters
[in]membersContains the list of all members that are in the current view.
[in]unreachableContains the list of members that are unreachable in the current view, i.e., a subset of members.

Implements Gcs_control_event_listener.

◆ on_view_changed()

void Plugin_gcs_events_handler::on_view_changed ( const Gcs_view new_view,
const Exchanged_data exchanged_data 
) const
overridevirtual

This method is called when the view is ready to be installed.

The contents of Exchanged_data will be released by MySQL GCS after this handler finishes. Therefore the application MUST copy the contents of exchanged_data if it needs it at a later stage.

Parameters
[in]new_viewa reference to the new view.
[in]exchanged_datathe data handed out by other members.

Implements Gcs_control_event_listener.

◆ pre_process_message()

bool Plugin_gcs_events_handler::pre_process_message ( Plugin_gcs_message plugin_message,
const std::string &  message_origin 
) const
private

This method passes the message to message listeners.

Parameters
plugin_messageA pointer to the processed plugin gcs message
message_originA id of the message originating member
Returns
true if the message should be skipped, false otherwise

◆ process_local_exchanged_data()

int Plugin_gcs_events_handler::process_local_exchanged_data ( const Exchanged_data exchanged_data,
bool  is_joining 
) const
private

◆ set_stop_wait_timeout()

void Plugin_gcs_events_handler::set_stop_wait_timeout ( ulong  timeout)
inline

Sets the component stop timeout.

Parameters
[in]timeoutthe timeout

◆ update_group_info_manager()

int Plugin_gcs_events_handler::update_group_info_manager ( const Gcs_view new_view,
const Exchanged_data exchanged_data,
bool  is_joining,
bool  is_leaving 
) const
private

◆ update_member_status()

void Plugin_gcs_events_handler::update_member_status ( const std::vector< Gcs_member_identifier > &  members,
Group_member_info::Group_member_status  status,
Group_member_info::Group_member_status  old_equal_to,
Group_member_info::Group_member_status  old_different_from 
) const
private

This method updates the status of the members in the list according to the given parameters.

Parameters
membersthe vector with members to change the status to
statusthe status to change to.
old_equal_tochange if the old status is equal to
old_different_fromchange if the old status if different from
Note
When not using the old_equal_to and old_different_from parameters, you can pass the Group_member_info::MEMBER_END value.

◆ was_member_expelled_from_group()

bool Plugin_gcs_events_handler::was_member_expelled_from_group ( const Gcs_view view) const
private

This method checks if member was expelled from the group due to network failures.

Parameters
[in]viewthe view delivered by the GCS
Return values
truethe member was expelled
falseotherwise

Member Data Documentation

◆ applier_module

Applier_module_interface* Plugin_gcs_events_handler::applier_module
private

◆ compatibility_manager

Compatibility_module* Plugin_gcs_events_handler::compatibility_manager
private

◆ joiner_compatibility_status

st_compatibility_types* Plugin_gcs_events_handler::joiner_compatibility_status
private

The status of this member when it joins.

◆ m_notification_ctx

Notification_context Plugin_gcs_events_handler::m_notification_ctx
mutableprivate

The notification context for the GCS delivery thread.

◆ recovery_module

Recovery_module* Plugin_gcs_events_handler::recovery_module
private

◆ set_number_of_members_on_view_changed_to_10

bool Plugin_gcs_events_handler::set_number_of_members_on_view_changed_to_10
private

◆ stop_wait_timeout

ulong Plugin_gcs_events_handler::stop_wait_timeout
private

◆ temporary_states

std::set<Group_member_info *, Group_member_info_pointer_comparator>* Plugin_gcs_events_handler::temporary_states
private

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