MySQL 8.0.40
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 @return false in case of success, or true otherwise
108 */
110
111 /**
112 Signal that the read mode is ready on this member
113 @returns false in case of success, or true otherwise
114 */
116
117 /** The election thread status */
119 /** Is the process aborted */
121
122 /** Waiting for old primary transaction execution */
124 /* Is the primary ready? */
126 /** Are all group members in read mode */
128 /** Process is waiting on read mode - stage related var*/
130
131 /** The election invocation context */
133
134 /** The primary to be elected */
135 std::string primary_uuid;
136
137 /** The number of known members when the election started */
139 /** The members known for the current action */
140 std::list<std::string> known_members_addresses;
141
142 /** The stage handler for progress reporting */
144
145 /* Component stop timeout on shutdown */
147
148 // Run thread locks and conditions
149
150 /** The thread run lock*/
152 /** The thread run condition*/
154 /** The thread handle*/
156};
157
158#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:119
int terminate_election_process(bool wait=true)
Terminate the election process on shutdown.
Definition: primary_election_secondary_process.cc:406
my_thread_handle primary_election_pthd
The thread handle.
Definition: primary_election_secondary_process.h:155
~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:132
std::list< std::string > known_members_addresses
The members known for the current action.
Definition: primary_election_secondary_process.h:140
bool election_process_aborted
Is the process aborted.
Definition: primary_election_secondary_process.h:120
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:343
bool is_waiting_on_read_mode_group
Process is waiting on read mode - stage related var.
Definition: primary_election_secondary_process.h:129
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:286
ulong number_of_know_members
The number of known members when the election started.
Definition: primary_election_secondary_process.h:138
thread_state election_process_thd_state
The election thread status.
Definition: primary_election_secondary_process.h:118
Plugin_stage_monitor_handler * stage_handler
The stage handler for progress reporting.
Definition: primary_election_secondary_process.h:143
std::string primary_uuid
The primary to be elected.
Definition: primary_election_secondary_process.h:135
bool enable_read_mode_on_server()
Enables the read mode in the server.
Definition: primary_election_secondary_process.cc:265
mysql_mutex_t election_lock
The thread run lock.
Definition: primary_election_secondary_process.h:151
ulong stop_wait_timeout
Definition: primary_election_secondary_process.h:146
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:349
bool group_in_read_mode
Are all group members in read mode.
Definition: primary_election_secondary_process.h:127
bool waiting_on_old_primary_transactions
Waiting for old primary transaction execution.
Definition: primary_election_secondary_process.h:123
bool primary_ready
Definition: primary_election_secondary_process.h:125
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:153
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:261
bool signal_read_mode_ready()
Signal that the read mode is ready on this member.
Definition: primary_election_secondary_process.cc:280
std::vector< Group_member_info *, Malloc_allocator< Group_member_info * > > Group_member_info_list
Definition: member_info.h:735
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:496
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:52
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Definition: plugin_utils.h:47