MySQL  8.0.21
Source Code Documentation
plugin.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PLUGIN_INCLUDE
24 #define PLUGIN_INCLUDE
25 
27 #include <mysql/plugin.h>
29 
53 
54 // Forward declarations
55 class Autorejoin_thread;
57 
58 // Definition of system var structures
59 
60 // Definition of system vars structure for access their information in the
61 // plugin
62 struct SYS_VAR {
64 };
65 
66 /**
67  Position of channel observation manager's in channel_observation_manager_list
68 */
73 };
74 
75 /**
76  @enum enum_exit_state_action
77  @brief Action performed when the member leaves the group
78  unexpectedly.
79 */
84 };
85 
86 /**
87  This struct provides a namespace for the GR layer components.
88 */
89 struct gr_modules {
90  /**
91  @enum gr_modules_enum
92  @brief Represents the GR layer modules that can be initialized
93  and/or terminated at will while the plugin is running.
94  @see terminate_plugin_modules
95  */
97  RECOVERY_MODULE = 0,
115  NUM_MODULES
116  };
117  using mask = std::bitset<NUM_MODULES>;
118  static constexpr mask all_modules = (1 << NUM_MODULES) - 1;
119 };
120 
121 /**
122  @enum enum_tls_source_values
123  @brief Source of TLS configuration for the connection between Group
124  Replication members.
125 */
129 };
130 
131 /**
132  The plugin modules.
133 
134  @note Whenever you want to create a new plugin module, be sure to add it to
135  the gr_modules enum (@sa gr_modules) and see if it's part of the rejoin
136  process.
137 */
138 extern Gcs_operations *gcs_module;
148 // Lock for the applier and recovery module to prevent the race between STOP
149 // Group replication and ongoing transactions.
158 
159 // Auxiliary Functionality
166 // Latch used as the control point of the event driven
167 // management of the transactions.
170 
171 // Plugin global methods
173 void *get_plugin_pointer();
177  Delayed_initialization_thread *delayed_init_thd);
178 int initialize_plugin_modules(gr_modules::mask modules_to_init);
179 int terminate_plugin_modules(gr_modules::mask modules_to_terminate,
180  char **error_message = nullptr,
181  bool rejoin = false);
190 void reset_auto_increment_handler_values(bool force_reset = false);
191 SERVICE_TYPE(registry) * get_plugin_registry();
193 bool is_autorejoin_enabled();
197 
198 /**
199  Encapsulates the logic necessary to attempt a rejoin, i.e. gracefully leave
200  the group, terminate GCS infrastructure, terminate auto-rejoin relevant plugin
201  modules, reinitialize auto-rejoin relevant plugin modules, reinitialize GCS
202  infrastructure and attempt to join the group again.
203 
204  @returns a flag indicating success or failure.
205  @retval true the rejoin failed.
206  @retval false the rejoin succeeded.
207 */
208 bool attempt_rejoin();
215 const char *get_group_name_var();
230 
231 // Plugin public methods
234 int plugin_group_replication_start(char **error_message = nullptr);
235 int plugin_group_replication_stop(char **error_message = nullptr);
241 void terminate_wait_on_start_process(bool abort = false);
242 void set_wait_on_start_process(bool cond);
248  uint index,
251 
252 /**
253  Method to set retrieved certification info from a recovery channel extracted
254  from a given View_change event
255 
256  @note a copy of the certification info is made here.
257 
258  @param info the given view_change_event.
259 */
261 
262 #endif /* PLUGIN_INCLUDE */
int get_flow_control_member_quota_percent_var()
Definition: plugin.cc:252
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Blocked_transaction_handler * blocked_transaction_handler
The handler for transaction killing when an error or partition happens.
Definition: plugin.cc:106
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:71
Message_service_handler * message_service_handler
The thread that handles the message service process.
Definition: plugin.cc:116
Primary_election_handler * primary_election_handler
The primary election handler.
Definition: plugin.cc:110
Ticket register/wait auxiliary class.
Definition: plugin_utils.h:487
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:93
int plugin_group_replication_start(char **error_message=nullptr)
Definition: plugin.cc:392
A class to hold different channel observation manager.
Definition: channel_observation_manager.h:64
Definition: plugin.h:114
Definition: plugin.h:102
void set_wait_on_start_process(bool cond)
Set condition to block or unblock the calling threads.
Definition: plugin.cc:289
Shared_writelock * shared_plugin_stop_lock
Class to coordinate access to the plugin stop lock.
Definition: plugin.cc:100
Delayed_initialization_thread * delayed_initialization_thread
Initialization thread for server starts.
Definition: plugin.cc:102
enum_tls_source_values
Source of TLS configuration for the connection between Group Replication members. ...
Definition: plugin.h:126
bool get_allow_local_lower_version_join()
Definition: plugin.cc:2229
ulong get_exit_state_action_var()
Definition: plugin.cc:232
Definition: plugin.h:127
int plugin_group_replication_deinit(void *p)
Definition: plugin.cc:1696
Definition: plugin.h:62
Definition: delayed_plugin_initialization.h:28
Definition: plugin.h:104
bool plugin_get_group_member_stats(uint index, const GROUP_REPLICATION_GROUP_MEMBER_STATS_CALLBACKS &callbacks)
Definition: plugin.cc:383
Definition: plugin_utils.h:783
ulong get_components_stop_timeout_var()
Definition: plugin.cc:266
Definition: plugin.h:128
Definition: recovery.h:44
Definition: member_info.h:602
void enable_server_shutdown_status()
Definition: plugin.cc:218
Coordinates all operations to GCS interface.
Definition: gcs_operations.h:41
Definition: group_partition_handling.h:29
Definition: compatibility_module.h:39
mysql_service_mysql_runtime_error_t * mysql_runtime_error_service
Definition: plugin.cc:131
Transaction_consistency_manager * transaction_consistency_manager
The plugin transaction consistency manager.
Definition: plugin.cc:98
Definition: plugin.h:112
Definition: plugin_group_replication.h:53
long get_flow_control_applier_threshold_var()
Definition: plugin.cc:240
bool get_server_shutdown_status()
Definition: plugin.cc:220
Definition: plugin.h:83
Definition: plugin.h:108
bool get_plugin_is_setting_read_mode()
Definition: plugin.cc:226
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:203
int get_flow_control_release_percent_var()
Definition: plugin.cc:262
Definition: plugin.h:107
Definition: member_info.h:78
Gcs_operations * gcs_module
The plugin modules.
Definition: plugin.cc:82
long get_flow_control_min_recovery_quota_var()
Definition: plugin.cc:246
bool get_plugin_is_stopping()
Definition: plugin.cc:212
Definition: plugin.h:82
const mysql_service_registry_t * get_plugin_registry()
Definition: plugin.cc:2252
bool is_plugin_waiting_to_set_server_read_mode()
Definition: plugin.cc:2239
Definition: plugin.h:103
Definition: plugin.h:113
long get_flow_control_max_quota_var()
Definition: plugin.cc:250
void set_single_primary_mode_var(bool option)
Definition: plugin.cc:2248
Wait_ticket< my_thread_id > * transactions_latch
Transactions latch.
Definition: plugin.cc:96
void set_enforce_update_everywhere_checks(bool option)
Definition: plugin.cc:2244
Group_transaction_observation_manager * group_transaction_observation_manager
The transaction observation module.
Definition: plugin.cc:93
bool initiate_wait_on_start_process()
Blocks the calling thread.
Definition: plugin.cc:296
Definition: group_transaction_observation_manager.h:86
int get_flow_control_hold_percent_var()
Definition: plugin.cc:258
void reset_auto_increment_handler_values(bool force_reset=false)
Definition: plugin.cc:1932
int terminate_plugin_modules(gr_modules::mask modules_to_terminate, char **error_message=nullptr, bool rejoin=false)
Definition: plugin.cc:1212
structure to define some default "config_option" option settings
Definition: innodb_config.h:180
Plugin_waitlock * get_plugin_online_lock()
Definition: asynchronous_channels_state_observer.h:29
Autorejoin_thread * autorejoin_module
The thread that handles the auto-rejoin process.
Definition: plugin.cc:112
Definition: plugin_utils.h:696
bool plugin_get_connection_status(const GROUP_REPLICATION_CONNECTION_STATUS_CALLBACKS &callbacks)
Definition: plugin.cc:351
bool check_async_channel_running_on_secondary()
Definition: plugin.cc:2146
Definition: applier.h:281
rpl_sidno get_group_sidno()
Definition: plugin.cc:207
Channel_observation_manager_list * channel_observation_manager_list
The channel observation modules.
Definition: plugin.cc:88
bool plugin_is_group_replication_cloning()
Definition: plugin.cc:191
Definition: test_mysql_runtime_error.cc:29
void * MYSQL_PLUGIN
Definition: plugin.h:73
Group_events_observation_manager * group_events_observation_manager
The observation module for group events.
Definition: plugin.cc:86
This is the interface for the registrty module.
Definition: registry.h:37
bool plugin_is_group_replication_running()
Definition: plugin.cc:187
void set_error_state_due_to_error_during_autorejoin()
Definition: plugin.cc:270
This struct provides a namespace for the GR layer components.
Definition: plugin.h:89
#define SERVICE_TYPE_NO_CONST(name)
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:34
long get_flow_control_certifier_threshold_var()
Definition: plugin.cc:236
Plugin_gcs_events_handler * events_handler
Definition: plugin.cc:120
unsigned int uint
Definition: uca-dump.cc:29
enum_exit_state_action
Action performed when the member leaves the group unexpectedly.
Definition: plugin.h:80
void register_server_reset_master()
Definition: plugin.cc:2227
Group_member_info * local_member_info
Definition: plugin.cc:125
bool is_plugin_auto_starting_on_non_bootstrap_member()
Definition: plugin.cc:195
bool plugin_get_group_members(uint index, const GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS &callbacks)
Definition: plugin.cc:359
Definition: plugin_group_replication.h:72
Remote_clone_handler * remote_clone_handler
The handler to invoke clone.
Definition: plugin.cc:114
Applier_module * applier_module
The plugin applier.
Definition: plugin.cc:78
uint plugin_get_group_members_number()
Definition: plugin.cc:372
bool get_wait_on_engine_initialization()
Definition: plugin.cc:214
int initialize_plugin_and_join(enum_plugin_con_isolation sql_api_isolation, Delayed_initialization_thread *delayed_init_thd)
Definition: plugin.cc:550
Definition: plugin.h:101
long get_flow_control_min_quota_var()
Definition: plugin.cc:244
Definition: plugin_group_replication.h:97
Asynchronous_channels_state_observer * asynchronous_channels_state_observer
The Single primary channel observation module.
Definition: plugin.cc:90
int get_flow_control_period_var()
Definition: plugin.cc:256
int plugin_group_replication_init(MYSQL_PLUGIN plugin_info)
Definition: plugin.cc:1556
const char * get_group_name_var()
Definition: plugin.cc:230
Group_partition_handling * group_partition_handler
The transaction handler for network partitions.
Definition: plugin.cc:104
void set_auto_increment_handler_values()
Definition: plugin.cc:1927
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:357
void set_plugin_is_setting_read_mode(bool value)
Definition: plugin.cc:222
bool get_error_state_due_to_error_during_autorejoin()
Definition: plugin.cc:274
Group_member_info_manager_interface * group_member_mgr
Definition: plugin.cc:124
int plugin_group_replication_stop(char **error_message=nullptr)
Definition: plugin.cc:981
Class alerts listeners of group events like view changes and elections.
Definition: group_event_observer.h:86
int initialize_plugin_modules(gr_modules::mask modules_to_init)
Definition: plugin.cc:1079
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
bool is_plugin_configured_and_starting()
Definition: plugin.cc:199
Represents and encapsulates the logic responsible for handling the auto-rejoin process within Group R...
Definition: autorejoin.h:48
ulonglong get_rejoin_timeout()
Definition: plugin.cc:282
Definition: plugin.h:111
The base class to request and execute an election.
Definition: primary_election_invocation_handler.h:40
ulong get_flow_control_mode_var()
Definition: plugin.cc:234
The consistency information of all ongoing transactions which have consistency GROUP_REPLICATION_CONS...
Definition: consistency_manager.h:207
void terminate_wait_on_start_process(bool abort=false)
Release all the blocked threads.
Definition: plugin.cc:313
uint get_number_of_autorejoin_tries()
Definition: plugin.cc:280
API for Group Replication plugin.
ulong get_transaction_size_limit()
Definition: plugin.cc:2234
Group_action_coordinator * group_action_coordinator
The coordinator for group actions.
Definition: plugin.cc:108
Definition: plugin.h:106
void declare_plugin_cloning(bool is_running)
Definition: plugin.cc:1866
Definition: plugin.h:110
Definition: gcs_event_handlers.h:57
Definition: plugin.h:109
const char * p
Definition: ctype-mb.cc:1235
const string value("\alue\)
bool attempt_rejoin()
Encapsulates the logic necessary to attempt a rejoin, i.e.
Definition: plugin.cc:1428
std::bitset< NUM_MODULES > mask
Definition: plugin.h:117
Log info(cout, "NOTE")
Handles the deliver of recv service messages to subscribed modules.
Definition: message_service.h:44
void * get_plugin_pointer()
Definition: plugin.cc:183
enum_channel_observation_manager_position
Position of channel observation manager&#39;s in channel_observation_manager_list.
Definition: plugin.h:69
static const sasl_callback_t callbacks[]
Definition: auth_ldap_sasl_client.h:44
#define SERVICE_TYPE(name)
Definition: plugin.h:81
Definition: plugin_utils.h:95
gr_modules_enum
Represents the GR layer modules that can be initialized and/or terminated at will while the plugin is...
Definition: plugin.h:96
Definition: plugin.h:100
The coordinator class where group actions are submitted.
Definition: group_action_coordinator.h:53
MYSQL_PLUGIN_VAR_HEADER
Definition: plugin.h:63
bool server_engine_initialized()
Definition: plugin.cc:2222
mysql_mutex_t * get_plugin_running_lock()
Definition: plugin.cc:185
Compatibility_module * compatibility_mgr
Definition: plugin.cc:128
Recovery_module * recovery_module
The plugin recovery module.
Definition: plugin.cc:80
bool is_autorejoin_enabled()
Definition: plugin.cc:278
enum_plugin_con_isolation
What is the policy when creation a new server session for SQL execution.
Definition: sql_service_command.h:37
Registry_module_interface * registry_module
The registry module.
Definition: plugin.cc:84