MySQL 8.3.0
Source Code Documentation
primary_election_secondary_process.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2023, 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 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 PRIMARY_ELECTION_SECONDARY_PROCESS_INCLUDED
24#define PRIMARY_ELECTION_SECONDARY_PROCESS_INCLUDED
25
26#include <list>
27#include <string>
28
34
35/**
36 @class Primary_election_secondary_process
37 Class that contains the primary election process logic for secondary members
38*/
40 public:
41 /**
42 Class constructor for secondary election process
43 */
45
46 /**
47 Class destructor for secondary election process
48 */
50
51 /**
52 Launch the local process on the secondary members for primary election
53
54 @param election_mode the context on which election is occurring
55 @param primary_to_elect the uuid of the primary to elect
56 @param group_members_info the member info about group members
57
58 @returns 0 in case of success, or 1 otherwise
59 */
61 enum_primary_election_mode election_mode, std::string &primary_to_elect,
62 Group_member_info_list *group_members_info);
63
64 /**
65 Is the election process running?
66 @returns election_process_running
67 */
69
70 /**
71 Terminate the election process on shutdown
72 */
73 int terminate_election_process(bool wait = true);
74
75 /*
76 Internal thread execution method with the election process
77 */
79
80 /**
81 Sets the component stop timeout.
82
83 @param[in] timeout the timeout
84 */
86
87 private:
88 // The listeners for group events
89
90 int after_view_change(const std::vector<Gcs_member_identifier> &joining,
91 const std::vector<Gcs_member_identifier> &leaving,
92 const std::vector<Gcs_member_identifier> &group,
93 bool is_leaving, bool *skip_election,
95 std::string &suggested_primary) override;
97 std::string primary_uuid,
101 const std::string &message_origin,
102 bool *skip_message) override;
103
104 /**
105 Enables the read mode in the server
106 @return false in case of success, or true otherwise
107 */
109
110 /**
111 Signal that the read mode is ready on this member
112 @returns false in case of success, or true otherwise
113 */
115
116 /** The election thread status */
118 /** Is the process aborted */
120
121 /** Waiting for old primary transaction execution */
123 /* Is the primary ready? */
125 /** Are all group members in read mode */
127 /** Process is waiting on read mode - stage related var*/
129
130 /** The election invocation context */
132
133 /** The primary to be elected */
134 std::string primary_uuid;
135
136 /** The number of known members when the election started */
138 /** The members known for the current action */
139 std::list<std::string> known_members_addresses;
140
141 /** The stage handler for progress reporting */
143
144 /* Component stop timeout on shutdown */
146
147 // Run thread locks and conditions
148
149 /** The thread run lock*/
151 /** The thread run condition*/
153 /** The thread handle*/
155};
156
157#endif /* PRIMARY_ELECTION_SECONDARY_PROCESS_INCLUDED */
Class that others can extend to receive notifications about views and primary elections.
Definition: group_event_observer.h:39
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
Definition: stage_monitor_handler.h:29
Class that contains the primary election process logic for secondary members.
Definition: primary_election_secondary_process.h:39
int secondary_election_process_handler()
Definition: primary_election_secondary_process.cc:118
int terminate_election_process(bool wait=true)
Terminate the election process on shutdown.
Definition: primary_election_secondary_process.cc:405
my_thread_handle primary_election_pthd
The thread handle.
Definition: primary_election_secondary_process.h:154
~Primary_election_secondary_process() override
Class destructor for secondary election process.
Definition: primary_election_secondary_process.cc:49
enum_primary_election_mode election_mode
The election invocation context.
Definition: primary_election_secondary_process.h:131
std::list< std::string > known_members_addresses
The members known for the current action.
Definition: primary_election_secondary_process.h:139
bool election_process_aborted
Is the process aborted.
Definition: primary_election_secondary_process.h:119
int after_primary_election(std::string primary_uuid, enum_primary_election_primary_change_status primary_change_status, enum_primary_election_mode election_mode, int error) override
Executed after primary election.
Definition: primary_election_secondary_process.cc:342
bool is_waiting_on_read_mode_group
Process is waiting on read mode - stage related var.
Definition: primary_election_secondary_process.h:128
void set_stop_wait_timeout(ulong timeout)
Sets the component stop timeout.
Definition: primary_election_secondary_process.cc:54
int after_view_change(const std::vector< Gcs_member_identifier > &joining, const std::vector< Gcs_member_identifier > &leaving, const std::vector< Gcs_member_identifier > &group, bool is_leaving, bool *skip_election, enum_primary_election_mode *election_mode, std::string &suggested_primary) override
Executed after view install and before primary election.
Definition: primary_election_secondary_process.cc:285
ulong number_of_know_members
The number of known members when the election started.
Definition: primary_election_secondary_process.h:137
thread_state election_process_thd_state
The election thread status.
Definition: primary_election_secondary_process.h:117
Plugin_stage_monitor_handler * stage_handler
The stage handler for progress reporting.
Definition: primary_election_secondary_process.h:142
std::string primary_uuid
The primary to be elected.
Definition: primary_election_secondary_process.h:134
bool enable_read_mode_on_server()
Enables the read mode in the server.
Definition: primary_election_secondary_process.cc:264
mysql_mutex_t election_lock
The thread run lock.
Definition: primary_election_secondary_process.h:150
ulong stop_wait_timeout
Definition: primary_election_secondary_process.h:145
int before_message_handling(const Plugin_gcs_message &message, const std::string &message_origin, bool *skip_message) override
Executed before the message is processed.
Definition: primary_election_secondary_process.cc:348
bool group_in_read_mode
Are all group members in read mode.
Definition: primary_election_secondary_process.h:126
bool waiting_on_old_primary_transactions
Waiting for old primary transaction execution.
Definition: primary_election_secondary_process.h:122
bool primary_ready
Definition: primary_election_secondary_process.h:124
Primary_election_secondary_process()
Class constructor for secondary election process.
Definition: primary_election_secondary_process.cc:35
mysql_cond_t election_cond
The thread run condition.
Definition: primary_election_secondary_process.h:152
int launch_secondary_election_process(enum_primary_election_mode election_mode, std::string &primary_to_elect, Group_member_info_list *group_members_info)
Launch the local process on the secondary members for primary election.
Definition: primary_election_secondary_process.cc:58
bool is_election_process_running()
Is the election process running?
Definition: primary_election_secondary_process.cc:260
bool signal_read_mode_ready()
Signal that the read mode is ready on this member.
Definition: primary_election_secondary_process.cc:279
std::vector< Group_member_info *, Malloc_allocator< Group_member_info * > > Group_member_info_list
Definition: member_info.h:750
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:497
static int wait(mysql_cond_t *that, mysql_mutex_t *mutex_arg, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:62
enum_primary_election_mode
Enum for election types.
Definition: primary_election_include.h:32
enum_primary_election_primary_change_status
Enum for primary change status.
Definition: primary_election_include.h:49
Definition: my_thread_bits.h:57
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: plugin_utils.h:47