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