MySQL  8.0.19
Source Code Documentation
plugin.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2019, 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 
26 #include <mysql/plugin.h>
28 
52 
53 // Forward declarations
54 class Autorejoin_thread;
55 class Hold_transactions;
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  */
116  };
117  using mask = std::bitset<NUM_MODULES>;
118  static constexpr mask all_modules = (1 << NUM_MODULES) - 1;
119 };
120 
121 /**
122  The plugin modules.
123 
124  @note Whenever you want to create a new plugin module, be sure to add it to
125  the gr_modules enum (@sa gr_modules) and see if it's part of the rejoin
126  process.
127 */
128 extern Gcs_operations *gcs_module;
138 // Lock for the applier and recovery module to prevent the race between STOP
139 // Group replication and ongoing transactions.
149 
150 // Auxiliary Functionality
157 // Latch used as the control point of the event driven
158 // management of the transactions.
160 
161 // Plugin global methods
163 void *get_plugin_pointer();
167  Delayed_initialization_thread *delayed_init_thd);
168 int initialize_plugin_modules(gr_modules::mask modules_to_init);
169 int terminate_plugin_modules(gr_modules::mask modules_to_terminate,
170  char **error_message = nullptr,
171  bool rejoin = false);
180 void reset_auto_increment_handler_values(bool force_reset = false);
181 SERVICE_TYPE(registry) * get_plugin_registry();
183 bool is_autorejoin_enabled();
187 
188 /**
189  Encapsulates the logic necessary to attempt a rejoin, i.e. gracefully leave
190  the group, terminate GCS infrastructure, terminate auto-rejoin relevant plugin
191  modules, reinitialize auto-rejoin relevant plugin modules, reinitialize GCS
192  infrastructure and attempt to join the group again.
193 
194  @returns a flag indicating success or failure.
195  @retval true the rejoin failed.
196  @retval false the rejoin succeeded.
197 */
198 bool attempt_rejoin();
205 const char *get_group_name_var();
220 
221 // Plugin public methods
224 int plugin_group_replication_start(char **error_message = NULL);
225 int plugin_group_replication_stop(char **error_message = NULL);
231 void terminate_wait_on_start_process(bool abort = false);
232 void set_wait_on_start_process(bool cond);
238  uint index,
241 
242 /**
243  Method to set retrieved certification info from a recovery channel extracted
244  from a given View_change event
245 
246  @note a copy of the certification info is made here.
247 
248  @param info the given view_change_event.
249 */
251 
252 #endif /* PLUGIN_INCLUDE */
server_engine_initialized
bool server_engine_initialized()
Definition: plugin.cc:2208
is_plugin_waiting_to_set_server_read_mode
bool is_plugin_waiting_to_set_server_read_mode()
Definition: plugin.cc:2225
gr_modules::GCS_EVENTS_HANDLER
@ GCS_EVENTS_HANDLER
Definition: plugin.h:111
Shared_writelock
Definition: plugin_utils.h:699
get_flow_control_member_quota_percent_var
int get_flow_control_member_quota_percent_var()
Definition: plugin.cc:248
get_flow_control_release_percent_var
int get_flow_control_release_percent_var()
Definition: plugin.cc:258
SYS_VAR::MYSQL_PLUGIN_VAR_HEADER
MYSQL_PLUGIN_VAR_HEADER
Definition: plugin.h:63
get_group_name_var
const char * get_group_name_var()
Definition: plugin.cc:226
plugin_get_connection_status
bool plugin_get_connection_status(const GROUP_REPLICATION_CONNECTION_STATUS_CALLBACKS &callbacks)
Definition: plugin.cc:347
attempt_rejoin
bool attempt_rejoin()
Encapsulates the logic necessary to attempt a rejoin, i.e.
Definition: plugin.cc:1419
get_plugin_is_setting_read_mode
bool get_plugin_is_setting_read_mode()
Definition: plugin.cc:222
plugin_group_replication_stop
int plugin_group_replication_stop(char **error_message=NULL)
Definition: plugin.cc:975
Compatibility_module
Definition: compatibility_module.h:39
get_plugin_is_stopping
bool get_plugin_is_stopping()
Definition: plugin.cc:208
Group_action_coordinator
Definition: group_action_coordinator.h:53
SYS_VAR
Definition: plugin.h:62
GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS
Definition: plugin_group_replication.h:72
NULL
#define NULL
Definition: types.h:55
gr_modules
This struct provides a namespace for the GR layer components.
Definition: plugin.h:89
get_exit_state_action_var
ulong get_exit_state_action_var()
Definition: plugin.cc:228
get_number_of_autorejoin_tries
uint get_number_of_autorejoin_tries()
Definition: plugin.cc:276
Group_transaction_observation_manager
Definition: group_transaction_observation_manager.h:86
Gcs_operations
Definition: gcs_operations.h:41
applier_module
Applier_module * applier_module
The plugin applier.
Definition: plugin.cc:78
group_action_coordinator.h
Group_member_info
Definition: member_info.h:78
get_flow_control_applier_threshold_var
long get_flow_control_applier_threshold_var()
Definition: plugin.cc:236
mysql_mutex_t
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
asynchronous_channels_state_observer.h
plugin_is_group_replication_cloning
bool plugin_is_group_replication_cloning()
Definition: plugin.cc:187
Group_events_observation_manager
Definition: group_event_observer.h:86
plugin_is_group_replication_running
bool plugin_is_group_replication_running()
Definition: plugin.cc:183
declare_plugin_cloning
void declare_plugin_cloning(bool is_running)
Definition: plugin.cc:1842
gr_modules::gr_modules_enum
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
value
const string value("\"Value\"")
enum_channel_observation_manager_position
enum_channel_observation_manager_position
Position of channel observation manager's in channel_observation_manager_list.
Definition: plugin.h:69
transaction_consistency_manager
Transaction_consistency_manager * transaction_consistency_manager
The plugin transaction consistency manager.
Definition: plugin.cc:98
gcs_event_handlers.h
rpl_sidno
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:94
read_mode_handler.h
get_group_sidno
rpl_sidno get_group_sidno()
Definition: plugin.cc:203
gcs_module
Gcs_operations * gcs_module
The plugin modules.
Definition: plugin.cc:82
recovery.h
recovery_module
Recovery_module * recovery_module
The plugin recovery module.
Definition: plugin.cc:80
get_plugin_running_lock
mysql_mutex_t * get_plugin_running_lock()
Definition: plugin.cc:181
registry.h
ps_information.h
get_flow_control_max_quota_var
long get_flow_control_max_quota_var()
Definition: plugin.cc:246
message_service.h
hold_transactions
Hold_transactions * hold_transactions
Hold transaction mechanism.
Definition: plugin.cc:112
gcs_view_modification_notifier.h
GROUP_REPLICATION_CONNECTION_STATUS_CALLBACKS
Definition: plugin_group_replication.h:53
remote_clone_handler.h
gr_modules::COMPATIBILITY_MANAGER
@ COMPATIBILITY_MANAGER
Definition: plugin.h:110
Hold_transactions
Definition: hold_transactions.h:35
END_CHANNEL_OBSERVATION_MANAGER_POS
@ END_CHANNEL_OBSERVATION_MANAGER_POS
Definition: plugin.h:72
GROUP_CHANNEL_OBSERVATION_MANAGER_POS
@ GROUP_CHANNEL_OBSERVATION_MANAGER_POS
Definition: plugin.h:70
get_plugin_pointer
void * get_plugin_pointer()
Definition: plugin.cc:179
plugin_group_replication_deinit
int plugin_group_replication_deinit(void *p)
Definition: plugin.cc:1678
message_service_handler
Message_service_handler * message_service_handler
The thread that handles the message service process.
Definition: plugin.cc:118
gr_modules::ASYNC_REPL_CHANNELS
@ ASYNC_REPL_CHANNELS
Definition: plugin.h:102
set_error_state_due_to_error_during_autorejoin
void set_error_state_due_to_error_during_autorejoin()
Definition: plugin.cc:266
register_server_reset_master
void register_server_reset_master()
Definition: plugin.cc:2213
plugin_info
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:71
is_running
int is_running(task_env *t)
Definition: task.c:1633
gr_modules::WAIT_ON_START
@ WAIT_ON_START
Definition: plugin.h:109
EXIT_STATE_ACTION_OFFLINE_MODE
@ EXIT_STATE_ACTION_OFFLINE_MODE
Definition: plugin.h:83
get_wait_on_engine_initialization
bool get_wait_on_engine_initialization()
Definition: plugin.cc:210
gr_modules::AUTOREJOIN_THREAD
@ AUTOREJOIN_THREAD
Definition: plugin.h:104
EXIT_STATE_ACTION_READ_ONLY
@ EXIT_STATE_ACTION_READ_ONLY
Definition: plugin.h:81
Asynchronous_channels_state_observer
Definition: asynchronous_channels_state_observer.h:29
shared_plugin_stop_lock
Shared_writelock * shared_plugin_stop_lock
Class to coordinate access to the plugin stop lock.
Definition: plugin.cc:100
ASYNC_CHANNEL_OBSERVATION_MANAGER_POS
@ ASYNC_CHANNEL_OBSERVATION_MANAGER_POS
Definition: plugin.h:71
events_handler
Plugin_gcs_events_handler * events_handler
Definition: plugin.cc:120
plugin.h
get_plugin_online_lock
Plugin_waitlock * get_plugin_online_lock()
blocked_transaction_handler
Blocked_transaction_handler * blocked_transaction_handler
The handler for transaction killing when an error or partition happens.
Definition: plugin.cc:106
compatibility_module.h
terminate_wait_on_start_process
void terminate_wait_on_start_process(bool abort=false)
Release all the blocked threads.
Definition: plugin.cc:309
group_events_observation_manager
Group_events_observation_manager * group_events_observation_manager
The observation module for group events.
Definition: plugin.cc:86
Registry_module_interface
This is the interface for the registrty module.
Definition: registry.h:37
group_transaction_observation_manager.h
get_flow_control_hold_percent_var
int get_flow_control_hold_percent_var()
Definition: plugin.cc:254
gr_modules::mask
std::bitset< NUM_MODULES > mask
Definition: plugin.h:117
plugin_group_replication_set_retrieved_certification_info
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:199
delayed_plugin_initialization.h
get_components_stop_timeout_var
ulong get_components_stop_timeout_var()
Definition: plugin.cc:262
Delayed_initialization_thread
Definition: delayed_plugin_initialization.h:28
get_server_shutdown_status
bool get_server_shutdown_status()
Definition: plugin.cc:216
gr_modules::REGISTRY_MODULE
@ REGISTRY_MODULE
Definition: plugin.h:108
group_action_coordinator
Group_action_coordinator * group_action_coordinator
The coordinator for group actions.
Definition: plugin.cc:108
Applier_module
Definition: applier.h:281
set_single_primary_mode_var
void set_single_primary_mode_var(bool option)
Definition: plugin.cc:2234
uint
unsigned int uint
Definition: uca-dump.cc:29
transactions_latch
Wait_ticket< my_thread_id > * transactions_latch
Transactions latch.
Definition: plugin.cc:96
auto_increment.h
Plugin_gcs_events_handler
Definition: gcs_event_handlers.h:57
gr_modules::all_modules
static constexpr mask all_modules
Definition: plugin.h:118
Group_member_info_manager_interface
Definition: member_info.h:573
group_transaction_observation_manager
Group_transaction_observation_manager * group_transaction_observation_manager
The transaction observation module.
Definition: plugin.cc:93
plugin_get_group_members_number
uint plugin_get_group_members_number()
Definition: plugin.cc:368
initialize_plugin_and_join
int initialize_plugin_and_join(enum_plugin_con_isolation sql_api_isolation, Delayed_initialization_thread *delayed_init_thd)
Definition: plugin.cc:527
is_plugin_configured_and_starting
bool is_plugin_configured_and_starting()
Definition: plugin.cc:195
registry_module
Registry_module_interface * registry_module
The registry module.
Definition: plugin.cc:84
is_autorejoin_enabled
bool is_autorejoin_enabled()
Definition: plugin.cc:274
group_member_mgr
Group_member_info_manager_interface * group_member_mgr
Definition: plugin.cc:124
autorejoin_module
Autorejoin_thread * autorejoin_module
The thread that handles the auto-rejoin process.
Definition: plugin.cc:114
plugin_group_replication_start
int plugin_group_replication_start(char **error_message=NULL)
Definition: plugin.cc:388
plugin_get_group_member_stats
bool plugin_get_group_member_stats(uint index, const GROUP_REPLICATION_GROUP_MEMBER_STATS_CALLBACKS &callbacks)
Definition: plugin.cc:379
plugin_group_replication_init
int plugin_group_replication_init(MYSQL_PLUGIN plugin_info)
Definition: plugin.cc:1547
check_async_channel_running_on_secondary
bool check_async_channel_running_on_secondary()
Definition: plugin.cc:2132
asynchronous_channels_state_observer
Asynchronous_channels_state_observer * asynchronous_channels_state_observer
The Single primary channel observation module.
Definition: plugin.cc:90
applier.h
plugin_get_group_members
bool plugin_get_group_members(uint index, const GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS &callbacks)
Definition: plugin.cc:355
gr_modules::RECOVERY_MODULE
@ RECOVERY_MODULE
Definition: plugin.h:97
get_flow_control_period_var
int get_flow_control_period_var()
Definition: plugin.cc:252
plugin_constants.h
enum_exit_state_action
enum_exit_state_action
Action performed when the member leaves the group unexpectedly.
Definition: plugin.h:80
callbacks
static const sasl_callback_t callbacks[]
Definition: auth_ldap_sasl_client.h:40
Channel_observation_manager_list
A class to hold different channel observation manager.
Definition: channel_observation_manager.h:64
SERVICE_TYPE
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:75
gr_modules::APPLIER_MODULE
@ APPLIER_MODULE
Definition: plugin.h:101
Recovery_module
Definition: recovery.h:44
get_transaction_size_limit
ulong get_transaction_size_limit()
Definition: plugin.cc:2220
enable_server_shutdown_status
void enable_server_shutdown_status()
Definition: plugin.cc:214
gr_modules::REMOTE_CLONE_HANDLER
@ REMOTE_CLONE_HANDLER
Definition: plugin.h:112
group_partition_handling.h
Primary_election_handler
Definition: primary_election_invocation_handler.h:40
set_auto_increment_handler_values
void set_auto_increment_handler_values()
Definition: plugin.cc:1903
get_rejoin_timeout
ulonglong get_rejoin_timeout()
Definition: plugin.cc:278
gr_modules::MESSAGE_SERVICE_HANDLER
@ MESSAGE_SERVICE_HANDLER
Definition: plugin.h:113
option
structure to define some default "config_option" option settings
Definition: innodb_config.h:180
gr_modules::BINLOG_DUMP_THREAD_KILL
@ BINLOG_DUMP_THREAD_KILL
Definition: plugin.h:114
gr_modules::GROUP_MEMBER_MANAGER
@ GROUP_MEMBER_MANAGER
Definition: plugin.h:107
get_flow_control_min_recovery_quota_var
long get_flow_control_min_recovery_quota_var()
Definition: plugin.cc:242
GROUP_REPLICATION_GROUP_MEMBER_STATS_CALLBACKS
Definition: plugin_group_replication.h:97
get_flow_control_certifier_threshold_var
long get_flow_control_certifier_threshold_var()
Definition: plugin.cc:232
group_event_observer.h
Transaction_consistency_manager
Definition: consistency_manager.h:206
EXIT_STATE_ACTION_ABORT_SERVER
@ EXIT_STATE_ACTION_ABORT_SERVER
Definition: plugin.h:82
is_plugin_auto_starting_on_non_bootstrap_member
bool is_plugin_auto_starting_on_non_bootstrap_member()
Definition: plugin.cc:191
get_error_state_due_to_error_during_autorejoin
bool get_error_state_due_to_error_during_autorejoin()
Definition: plugin.cc:270
gr_modules::CERTIFICATION_LATCH
@ CERTIFICATION_LATCH
Definition: plugin.h:106
Remote_clone_handler
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
Message_service_handler
Definition: message_service.h:44
gr_modules::AUTO_INCREMENT_HANDLER
@ AUTO_INCREMENT_HANDLER
Definition: plugin.h:100
reset_auto_increment_handler_values
void reset_auto_increment_handler_values(bool force_reset=false)
Definition: plugin.cc:1908
Group_partition_handling
Definition: group_partition_handling.h:29
Autorejoin_thread
Represents and encapsulates the logic responsible for handling the auto-rejoin process within Group R...
Definition: autorejoin.h:48
set_wait_on_start_process
void set_wait_on_start_process(bool cond)
Set condition to block or unblock the calling threads.
Definition: plugin.cc:285
local_member_info
Group_member_info * local_member_info
Definition: plugin.cc:125
MYSQL_PLUGIN
void * MYSQL_PLUGIN
Definition: plugin.h:73
gcs_operations.h
initialize_plugin_modules
int initialize_plugin_modules(gr_modules::mask modules_to_init)
Definition: plugin.cc:1070
compatibility_mgr
Compatibility_module * compatibility_mgr
Definition: plugin.cc:128
plugin_group_replication.h
gcs_interface.h
Blocked_transaction_handler
Definition: plugin_utils.h:95
ulong
unsigned long ulong
Definition: my_inttypes.h:48
initiate_wait_on_start_process
bool initiate_wait_on_start_process()
Blocks the calling thread.
Definition: plugin.cc:292
terminate_plugin_modules
int terminate_plugin_modules(gr_modules::mask modules_to_terminate, char **error_message=nullptr, bool rejoin=false)
Definition: plugin.cc:1203
enum_plugin_con_isolation
enum_plugin_con_isolation
What is the policy when creation a new server session for SQL execution.
Definition: sql_service_command.h:37
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
primary_election_invocation_handler.h
channel_observation_manager_list
Channel_observation_manager_list * channel_observation_manager_list
The channel observation modules.
Definition: plugin.cc:88
gr_modules::NUM_MODULES
@ NUM_MODULES
Definition: plugin.h:115
Wait_ticket
Ticket register/wait auxiliary class.
Definition: plugin_utils.h:487
get_flow_control_min_quota_var
long get_flow_control_min_quota_var()
Definition: plugin.cc:240
group_partition_handler
Group_partition_handling * group_partition_handler
The transaction handler for network partitions.
Definition: plugin.cc:104
get_plugin_registry
const mysql_service_registry_t * get_plugin_registry()
Definition: plugin.cc:2238
set_plugin_is_setting_read_mode
void set_plugin_is_setting_read_mode(bool value)
Definition: plugin.cc:218
gr_modules::PRIMARY_ELECTION_HANDLER
@ PRIMARY_ELECTION_HANDLER
Definition: plugin.h:99
gr_modules::BLOCKED_TRANSACTION_HANDLER
@ BLOCKED_TRANSACTION_HANDLER
Definition: plugin.h:105
Plugin_waitlock
Definition: plugin_utils.h:787
delayed_initialization_thread
Delayed_initialization_thread * delayed_initialization_thread
Initialization thread for server starts.
Definition: plugin.cc:102
p
const char * p
Definition: ctype-mb.cc:1233
get_allow_local_lower_version_join
bool get_allow_local_lower_version_join()
Definition: plugin.cc:2215
gr_modules::GROUP_PARTITION_HANDLER
@ GROUP_PARTITION_HANDLER
Definition: plugin.h:103
primary_election_handler
Primary_election_handler * primary_election_handler
The primary election handler.
Definition: plugin.cc:110
gr_modules::GROUP_ACTION_COORDINATOR
@ GROUP_ACTION_COORDINATOR
Definition: plugin.h:98
set_enforce_update_everywhere_checks
void set_enforce_update_everywhere_checks(bool option)
Definition: plugin.cc:2230
info
Log info(cout, "NOTE")
index
char * index(const char *, int c)
Definition: mysql.cc:2875
get_flow_control_mode_var
ulong get_flow_control_mode_var()
Definition: plugin.cc:230
plugin_server_include.h
remote_clone_handler
Remote_clone_handler * remote_clone_handler
The handler to invoke clone.
Definition: plugin.cc:116
channel_observation_manager.h