MySQL 9.1.0
Source Code Documentation
plugin.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef PLUGIN_INCLUDE
25#define PLUGIN_INCLUDE
26
28#include <mysql/plugin.h>
30
56
57// Forward declarations
61class Metrics_handler;
63class Mysql_thread;
64
65// Definition of system var structures
66
67// Definition of system vars structure for access their information in the
68// plugin
69struct SYS_VAR {
71};
72
73/**
74 Position of channel observation manager's in channel_observation_manager_list
75*/
80};
81
82/**
83 @enum enum_exit_state_action
84 @brief Action performed when the member leaves the group
85 unexpectedly.
86*/
91};
92
93/**
94 This struct provides a namespace for the GR layer components.
95*/
96struct gr_modules {
97 /**
98 @enum gr_modules_enum
99 @brief Represents the GR layer modules that can be initialized
100 and/or terminated at will while the plugin is running.
101 @see terminate_plugin_modules
102 */
126 };
127 using mask = std::bitset<NUM_MODULES>;
128 static constexpr mask all_modules = (1 << NUM_MODULES) - 1;
129};
130
131/**
132 @enum enum_tls_source_values
133 @brief Source of TLS configuration for the connection between Group
134 Replication members.
135*/
140
141/**
142 @enum enum_wait_on_start_process_result
143 @brief Reasons why asynchronous channels start wait for Group
144 Replication status can be aborted.
145*/
151
152/**
153 The plugin modules.
154
155 @note Whenever you want to create a new plugin module, be sure to add it to
156 the gr_modules enum (@sa gr_modules) and see if it's part of the rejoin
157 process.
158*/
169// Lock for the applier and recovery module to prevent the race between STOP
170// Group replication and ongoing transactions.
185
186// Auxiliary Functionality
194// Latch used as the control point of the event driven
195// management of the transactions.
197extern SERVICE_TYPE_NO_CONST(mysql_runtime_error) * mysql_runtime_error_service;
198
199// Plugin global methods
201void *get_plugin_pointer();
205 Delayed_initialization_thread *delayed_init_thd);
207int terminate_plugin_modules(gr_modules::mask modules_to_terminate,
208 char **error_message = nullptr,
209 bool rejoin = false);
216void set_single_primary_mode_var(bool option);
219void reset_auto_increment_handler_values(bool force_reset = false);
229/**
230 Encapsulates the logic necessary to attempt a rejoin, i.e. gracefully leave
231 the group, terminate GCS infrastructure, terminate auto-rejoin relevant plugin
232 modules, reinitialize auto-rejoin relevant plugin modules, reinitialize GCS
233 infrastructure and attempt to join the group again.
234
235 @returns a flag indicating success or failure.
236 @retval true the rejoin failed.
237 @retval false the rejoin succeeded.
238*/
239bool attempt_rejoin();
245void set_plugin_is_setting_read_mode(bool value);
247const char *get_group_name_var();
248const char *get_view_change_uuid_var();
264
265// Plugin public methods
268int plugin_group_replication_start(char **error_message = nullptr);
269int plugin_group_replication_stop(char **error_message = nullptr);
277void set_wait_on_start_process(bool cond);
281 uint index, const GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS &callbacks);
283 uint index,
287
288/**
289 Method to set retrieved certification info from a recovery channel extracted
290 from a given View_change event
291
292 @note a copy of the certification info is made here.
293
294 @param info the given view_change_event.
295*/
297
298#endif /* PLUGIN_INCLUDE */
Definition: applier.h:322
Definition: asynchronous_channels_state_observer.h:30
Represents and encapsulates the logic responsible for handling the auto-rejoin process within Group R...
Definition: autorejoin.h:49
Definition: plugin_utils.h:101
A class to hold different channel observation manager.
Definition: channel_observation_manager.h:65
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:325
Definition: compatibility_module.h:41
Deals with the orchestration necessary to set the appropriate "consensus leaders" on GCS.
Definition: consensus_leaders_handler.h:39
Definition: delayed_plugin_initialization.h:29
Coordinates all operations to GCS interface.
Definition: gcs_operations.h:49
The coordinator class where group actions are submitted.
Definition: group_action_coordinator.h:66
Class alerts listeners of group events like view changes and elections.
Definition: group_event_observer.h:87
Definition: member_info.h:787
Definition: member_info.h:82
Definition: group_partition_handling.h:30
Definition: group_transaction_observation_manager.h:89
Handles member actions configuration and trigger.
Definition: member_actions_handler.h:96
Handles the deliver of recv service messages to subscribed modules.
Definition: message_service.h:45
Definition: metrics_handler.h:40
A generic single thread executor.
Definition: mysql_thread.h:208
Definition: gcs_event_handlers.h:59
The base class to request and execute an election.
Definition: primary_election_invocation_handler.h:41
This class handles the recovery metadata.
Definition: recovery_metadata.h:43
Definition: recovery.h:39
This is the interface for the registrty module.
Definition: registry.h:38
Class that hold the logic to decide if we should or not execute a clone operation and the logic to la...
Definition: remote_clone_handler.h:35
This class holds the references to server services that Group Replication acquires on plugin install.
Definition: server_services_references.h:42
Definition: plugin_utils.h:733
The consistency information of all ongoing transactions which have consistency GROUP_REPLICATION_CONS...
Definition: consistency_manager.h:294
Ticket register/wait auxiliary class.
Definition: plugin_utils.h:524
const char * p
Definition: ctype-mb.cc:1225
void * MYSQL_PLUGIN
Definition: plugin.h:82
unsigned long long int ulonglong
Definition: my_inttypes.h:56
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:203
ulong get_flow_control_mode_var()
Definition: plugin.cc:329
bool plugin_get_group_member_stats(uint index, const GROUP_REPLICATION_GROUP_MEMBER_STATS_CALLBACKS &callbacks)
Definition: plugin.cc:536
int get_flow_control_release_percent_var()
Definition: plugin.cc:357
Group_action_coordinator * group_action_coordinator
The coordinator for group actions.
Definition: plugin.cc:123
Blocked_transaction_handler * blocked_transaction_handler
The handler for transaction killing when an error or partition happens.
Definition: plugin.cc:121
ulong get_transaction_size_limit()
Definition: plugin.cc:2868
Metrics_handler * metrics_handler
Definition: plugin.cc:146
enum_channel_observation_manager_position
Position of channel observation manager's in channel_observation_manager_list.
Definition: plugin.h:76
@ ASYNC_CHANNEL_OBSERVATION_MANAGER_POS
Definition: plugin.h:78
@ END_CHANNEL_OBSERVATION_MANAGER_POS
Definition: plugin.h:79
@ GROUP_CHANNEL_OBSERVATION_MANAGER_POS
Definition: plugin.h:77
Applier_module * applier_module
The plugin applier.
Definition: plugin.cc:91
int initialize_plugin_and_join(enum_plugin_con_isolation sql_api_isolation, Delayed_initialization_thread *delayed_init_thd)
Definition: plugin.cc:723
Server_services_references * server_services_references_module
Module with the acquired server services on plugin install.
Definition: plugin.cc:145
rpl_sidno get_view_change_sidno()
Definition: plugin.cc:269
int plugin_group_replication_init(MYSQL_PLUGIN plugin_info)
Definition: plugin.cc:2019
bool plugin_is_group_replication_cloning()
Definition: plugin.cc:248
ulong get_exit_state_action_var()
Definition: plugin.cc:327
bool get_allow_single_leader()
Definition: plugin.cc:373
bool is_plugin_auto_starting_on_non_bootstrap_member()
Definition: plugin.cc:252
void reset_auto_increment_handler_values(bool force_reset=false)
Definition: plugin.cc:2514
void mysql_thread_handler_finalize()
Definition: plugin.cc:1959
ulong get_components_stop_timeout_var()
Definition: plugin.cc:361
void set_wait_on_start_process(bool cond)
Set condition to block or unblock the calling threads.
Definition: plugin.cc:414
Group_member_info * local_member_info
Definition: plugin.cc:153
long get_flow_control_min_quota_var()
Definition: plugin.cc:339
bool plugin_get_connection_status(const GROUP_REPLICATION_CONNECTION_STATUS_CALLBACKS &callbacks)
Definition: plugin.cc:505
void set_plugin_is_setting_read_mode(bool value)
Definition: plugin.cc:315
Transaction_consistency_manager * transaction_consistency_manager
The plugin transaction consistency manager.
Definition: plugin.cc:113
enum_wait_on_start_process_result
Reasons why asynchronous channels start wait for Group Replication status can be aborted.
Definition: plugin.h:146
@ WAIT_ON_START_PROCESS_ABORT_SECONDARY_MEMBER
Definition: plugin.h:149
@ WAIT_ON_START_PROCESS_ABORT_ON_CLONE
Definition: plugin.h:148
@ WAIT_ON_START_PROCESS_SUCCESS
Definition: plugin.h:147
Autorejoin_thread * autorejoin_module
The thread that handles the auto-rejoin process.
Definition: plugin.cc:127
Recovery_metadata_module * recovery_metadata_module
The plugin recovery metadata module.
Definition: plugin.cc:95
Message_service_handler * message_service_handler
The thread that handles the message service process.
Definition: plugin.cc:131
bool is_autorejoin_enabled()
Definition: plugin.cc:367
uint get_preemptive_garbage_collection_rows_threshold_var()
Definition: plugin.cc:5320
const mysql_service_registry_t * get_plugin_registry()
Definition: plugin.cc:2888
bool get_server_shutdown_status()
Definition: plugin.cc:313
Checkable_rwlock * get_plugin_running_lock()
Definition: plugin.cc:238
bool plugin_is_group_replication_running()
Definition: plugin.cc:244
bool server_engine_initialized()
Definition: plugin.cc:2856
Mysql_thread * mysql_thread_handler
Handle tasks on mysql_thread.
Definition: plugin.cc:136
bool plugin_get_group_members(uint index, const GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS &callbacks)
Definition: plugin.cc:513
long get_flow_control_max_quota_var()
Definition: plugin.cc:345
void declare_plugin_cloning(bool is_running)
Definition: plugin.cc:2439
Group_partition_handling * group_partition_handler
The transaction handler for network partitions.
Definition: plugin.cc:119
Member_actions_handler * member_actions_handler
Definition: plugin.cc:134
bool check_async_channel_running_on_secondary()
Definition: plugin.cc:2777
mysql_mutex_t * get_plugin_applier_module_initialize_terminate_lock()
Definition: plugin.cc:240
Registry_module_interface * registry_module
The registry module.
Definition: plugin.cc:99
int initialize_plugin_modules(gr_modules::mask modules_to_init)
Definition: plugin.cc:1376
Group_transaction_observation_manager * group_transaction_observation_manager
The transaction observation module.
Definition: plugin.cc:108
mysql_service_mysql_runtime_error_t * mysql_runtime_error_service
Definition: plugin.cc:159
int plugin_group_replication_leave_group()
Definition: plugin.cc:1182
Channel_observation_manager_list * channel_observation_manager_list
The channel observation modules.
Definition: plugin.cc:103
Recovery_module * recovery_module
The plugin recovery module.
Definition: plugin.cc:93
Delayed_initialization_thread * delayed_initialization_thread
Initialization thread for server starts.
Definition: plugin.cc:117
Shared_writelock * shared_plugin_stop_lock
Class to coordinate access to the plugin stop lock.
Definition: plugin.cc:115
int get_flow_control_period_var()
Definition: plugin.cc:351
bool is_plugin_waiting_to_set_server_read_mode()
Definition: plugin.cc:2873
enum_tls_source_values
Source of TLS configuration for the connection between Group Replication members.
Definition: plugin.h:136
@ TLS_SOURCE_MYSQL_ADMIN
Definition: plugin.h:138
@ TLS_SOURCE_MYSQL_MAIN
Definition: plugin.h:137
const char * get_view_change_uuid_var()
Definition: plugin.cc:325
bool get_preemptive_garbage_collection_var()
Definition: plugin.cc:5279
Asynchronous_channels_state_observer * asynchronous_channels_state_observer
The Single primary channel observation module.
Definition: plugin.cc:105
void * get_plugin_pointer()
Definition: plugin.cc:236
Remote_clone_handler * remote_clone_handler
The handler to invoke clone.
Definition: plugin.cc:129
uint plugin_get_group_members_number()
Definition: plugin.cc:525
int plugin_group_replication_stop(char **error_message=nullptr)
Definition: plugin.cc:1254
bool get_wait_on_engine_initialization()
Definition: plugin.cc:307
bool is_plugin_configured_and_starting()
Definition: plugin.cc:256
uint get_number_of_autorejoin_tries()
Definition: plugin.cc:369
long get_flow_control_applier_threshold_var()
Definition: plugin.cc:335
int plugin_group_replication_set_retrieved_certification_info(void *info)
Method to set retrieved certification info from a recovery channel extracted from a given View_change...
Definition: plugin.cc:260
Plugin_gcs_events_handler * events_handler
Definition: plugin.cc:148
Group_events_observation_manager * group_events_observation_manager
The observation module for group events.
Definition: plugin.cc:101
Gcs_operations * gcs_module
The plugin modules.
Definition: plugin.cc:97
ulonglong get_rejoin_timeout()
Definition: plugin.cc:371
void terminate_wait_on_start_process(enum_wait_on_start_process_result abort=WAIT_ON_START_PROCESS_SUCCESS)
Release all the blocked threads.
Definition: plugin.cc:438
bool get_plugin_is_stopping()
Definition: plugin.cc:305
void set_single_primary_mode_var(bool option)
Definition: plugin.cc:2882
int get_flow_control_hold_percent_var()
Definition: plugin.cc:353
enum_exit_state_action
Action performed when the member leaves the group unexpectedly.
Definition: plugin.h:87
@ EXIT_STATE_ACTION_ABORT_SERVER
Definition: plugin.h:89
@ EXIT_STATE_ACTION_OFFLINE_MODE
Definition: plugin.h:90
@ EXIT_STATE_ACTION_READ_ONLY
Definition: plugin.h:88
const char * get_group_name_var()
Definition: plugin.cc:323
bool get_plugin_is_setting_read_mode()
Definition: plugin.cc:319
void set_auto_increment_handler_values()
Definition: plugin.cc:2509
ulong get_communication_stack_var()
Definition: plugin.cc:365
Mysql_thread * mysql_thread_handler_read_only_mode
Dedicated mysql_thread to enable read_only and super_read_only since these are blocking operations.
Definition: plugin.cc:143
Consensus_leaders_handler * consensus_leaders_handler
Definition: plugin.cc:162
Primary_election_handler * primary_election_handler
The primary election handler.
Definition: plugin.cc:125
bool attempt_rejoin()
Encapsulates the logic necessary to attempt a rejoin, i.e.
Definition: plugin.cc:1767
long get_flow_control_certifier_threshold_var()
Definition: plugin.cc:331
int plugin_group_replication_deinit(void *p)
Definition: plugin.cc:2211
bool get_allow_local_lower_version_join()
Definition: plugin.cc:2863
void enable_server_shutdown_status()
Definition: plugin.cc:311
rpl_sidno get_group_sidno()
Definition: plugin.cc:264
Group_member_info_manager_interface * group_member_mgr
Definition: plugin.cc:152
Compatibility_module * compatibility_mgr
Definition: plugin.cc:156
enum_wait_on_start_process_result initiate_wait_on_start_process()
Blocks the calling thread.
Definition: plugin.cc:421
int get_flow_control_member_quota_percent_var()
Definition: plugin.cc:347
void set_enforce_update_everywhere_checks(bool option)
Definition: plugin.cc:2878
int terminate_plugin_modules(gr_modules::mask modules_to_terminate, char **error_message=nullptr, bool rejoin=false)
Definition: plugin.cc:1536
int plugin_group_replication_start(char **error_message=nullptr)
Definition: plugin.cc:544
bool get_single_primary_mode_var()
Definition: plugin.cc:2886
bool is_view_change_log_event_required()
Definition: plugin.cc:274
long get_flow_control_min_recovery_quota_var()
Definition: plugin.cc:341
void register_server_reset_master()
Definition: plugin.cc:2861
Wait_ticket< my_thread_id > * transactions_latch
Transactions latch.
Definition: plugin.cc:111
API for Group Replication plugin.
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:89
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:109
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
#define SERVICE_TYPE_NO_CONST(name)
Generates the standard Service type name.
Definition: service.h:71
enum_plugin_con_isolation
What is the policy when creation a new server session for SQL execution.
Definition: sql_service_command.h:38
Definition: plugin_group_replication.h:54
Definition: plugin_group_replication.h:73
Definition: plugin_group_replication.h:101
Definition: plugin.h:69
MYSQL_PLUGIN_VAR_HEADER
Definition: plugin.h:70
This struct provides a namespace for the GR layer components.
Definition: plugin.h:96
static constexpr mask all_modules
Definition: plugin.h:128
std::bitset< NUM_MODULES > mask
Definition: plugin.h:127
gr_modules_enum
Represents the GR layer modules that can be initialized and/or terminated at will while the plugin is...
Definition: plugin.h:103
@ WAIT_ON_START
Definition: plugin.h:116
@ GROUP_ACTION_COORDINATOR
Definition: plugin.h:105
@ BLOCKED_TRANSACTION_HANDLER
Definition: plugin.h:112
@ AUTOREJOIN_THREAD
Definition: plugin.h:111
@ REMOTE_CLONE_HANDLER
Definition: plugin.h:119
@ MESSAGE_SERVICE_HANDLER
Definition: plugin.h:120
@ COMPATIBILITY_MANAGER
Definition: plugin.h:117
@ GROUP_PARTITION_HANDLER
Definition: plugin.h:110
@ NUM_MODULES
Definition: plugin.h:125
@ ASYNC_REPL_CHANNELS
Definition: plugin.h:109
@ RECOVERY_METADATA_MODULE
Definition: plugin.h:124
@ METRICS_HANDLER
Definition: plugin.h:123
@ AUTO_INCREMENT_HANDLER
Definition: plugin.h:107
@ RECOVERY_MODULE
Definition: plugin.h:104
@ GROUP_MEMBER_MANAGER
Definition: plugin.h:114
@ MEMBER_ACTIONS_HANDLER
Definition: plugin.h:122
@ BINLOG_DUMP_THREAD_KILL
Definition: plugin.h:121
@ PRIMARY_ELECTION_HANDLER
Definition: plugin.h:106
@ CERTIFICATION_LATCH
Definition: plugin.h:113
@ GCS_EVENTS_HANDLER
Definition: plugin.h:118
@ APPLIER_MODULE
Definition: plugin.h:108
@ REGISTRY_MODULE
Definition: plugin.h:115
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50