MySQL 8.0.40
Source Code Documentation
|
#include <gcs_event_handlers.h>
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_data * | get_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_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_members_leaving_message (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... | |
Private Attributes | |
Applier_module_interface * | applier_module |
Recovery_module * | recovery_module |
std::set< Group_member_info *, Group_member_info_pointer_comparator > * | temporary_states |
Compatibility_module * | compatibility_manager |
st_compatibility_types * | joiner_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... | |
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.
|
override |
|
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
number_of_members | the number of members in the new view |
0 | compatible |
>0 | not compatible with the group |
|
private |
When the member is joining, cycle through all members on group and see if it is compatible with them.
INCOMPATIBLE | //Versions not compatible |
COMPATIBLE | //Versions compatible |
READ_COMPATIBLE | //Member can read but not write |
|
private |
This method takes all the group executed sets and adds those belonging to non recovering member to the view change packet.
[in] | view_packet | the view change packet |
|
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
0 | Joiner has the same value as all other members |
!=0 | Otherwise |
|
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.
0 | Joiner has less GTIDs than the group |
>0 | Joiner has more GTIDS than the group |
<0 | Error when processing GTID information |
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.
[in] | force_check | Compatibility is mandatory re-checked |
|
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.
Implements Gcs_control_event_listener.
|
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.
[in] | members | joining or leaving members for this view |
[out] | all_hosts | host and port of all members from view |
[out] | primary_host | primary 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.
|
private |
|
private |
|
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.
|
private |
This method handles the election of a new primary node when the plugin runs in single primary mode.
election_mode | election type |
suggested_primary | what should be the next primary to elect |
|
private |
|
private |
Re-check compatibility, members may leave during recovery. Disable the read mode in the server if the member is:
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Check if a member is not entering a group where an action is running.
If action is running provide details of action.
[out] | group_action_running_initiator | Group action configuration initiator details |
[out] | group_action_running_description | Group action configuration description |
false | no group action is running |
true | a group action is running |
|
private |
Check if the group is running a primary election.
false | no primary election is running |
true | a primary election is running |
|
private |
Verifies if a certain Vector of Member Ids contains a given member id.
members | the vector with members to verify |
member_id | the member to check if it contained. |
|
private |
Logs member joining message to error logs from view.
[in] | new_view | the view delivered by the GCS |
|
private |
Logs member leaving message to error logs from view.
[in] | new_view | the view delivered by the GCS |
|
overridevirtual |
This method is called whenever a message is to be delivered.
[in] | message | The 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.
|
overridevirtual |
This member function is called when the set of suspicions has changed in the underlying communication infrastructure.
[in] | members | Contains the list of all members that are in the current view. |
[in] | unreachable | Contains the list of members that are unreachable in the current view, i.e., a subset of members . |
Implements Gcs_control_event_listener.
|
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.
[in] | new_view | a reference to the new view. |
[in] | exchanged_data | the data handed out by other members. |
Implements Gcs_control_event_listener.
|
private |
This method passes the message to message listeners.
plugin_message | A pointer to the processed plugin gcs message |
message_origin | A id of the message originating member |
|
private |
|
inline |
Sets the component stop timeout.
[in] | timeout | the timeout |
|
private |
|
private |
This method updates the status of the members in the list according to the given parameters.
members | the vector with members to change the status to |
status | the status to change to. |
old_equal_to | change if the old status is equal to |
old_different_from | change if the old status if different from |
|
private |
This method checks if member was expelled from the group due to network failures.
[in] | view | the view delivered by the GCS |
true | the member was expelled |
false | otherwise |
|
private |
|
private |
|
private |
The status of this member when it joins.
|
mutableprivate |
The notification context for the GCS delivery thread.
|
private |
|
private |
|
private |
|
private |