MySQL 8.0.39
Source Code Documentation
rpl_info_factory.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 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 RPL_INFO_FACTORY_H
25#define RPL_INFO_FACTORY_H
26
27#include <sys/types.h>
28#include <string>
29#include <vector>
30
31#include "my_bitmap.h"
32#include "my_io.h"
33#include "sql/rpl_info_handler.h" // enum_return_check
34
35class Master_info;
37class Relay_log_info;
38class Rpl_info;
39class Slave_worker;
40
41extern ulong opt_mi_repository_id;
42extern ulong opt_rli_repository_id;
43
45 public:
46 static bool create_slave_info_objects(uint mi_option, uint rli_option,
47 int thread_mask,
48 Multisource_info *pchannel_map);
49
50 /**
51 Establish the relation between the channel's replication filters and
52 the channel's Relay_log_info, and copy global replication filters to
53 the channel's replication filters if needed.
54
55 @param rli Pointer to Relay_log_info.
56 @param channel_name The channel name.
57
58 @retval false No error
59 @retval true Failure
60 */
62 const char *channel_name);
63
64 static Master_info *create_mi_and_rli_objects(uint mi_option, uint rli_option,
65 const char *channel,
66 bool convert_repo,
68
69 static Master_info *create_mi(uint rli_option, const char *channel,
70 bool conver_repo);
71 static bool change_mi_repository(Master_info *mi, const uint mi_option,
72 const char **msg);
73 static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery,
74 const char *channel, bool convert_repo);
75 static bool change_rli_repository(Relay_log_info *rli, const uint rli_option,
76 const char **msg);
77 static Slave_worker *create_worker(uint rli_option, uint worker_id,
78 Relay_log_info *rli,
79 bool is_gaps_collecting_phase);
80 static bool reset_workers(Relay_log_info *rli);
81 /**
82 If GTID_ONLY is set for this channel, receiver and applier positions
83 will be marked as invalid.
84
85 @param mi the repository info object whose positions will be invalidated
86 */
88
89 private:
90 typedef struct file_data {
94 bool name_indexed; // whether file name should include instance number
98
99 typedef struct table_data {
101 const char *schema;
102 const char *name;
108
115
116 static void init_repository_metadata();
117 static bool decide_repository(Rpl_info *info, uint option,
118 Rpl_info_handler **handler_src,
119 Rpl_info_handler **handler_dest,
120 const char **msg);
122 const struct_file_data &file_data, uint option,
123 Rpl_info_handler **handler_src,
124 Rpl_info_handler **handler_dest,
125 const char **msg);
126
128 Rpl_info_handler **handler_src);
129 static bool check_error_repository(Rpl_info_handler *handler_src,
130 Rpl_info_handler *handler_dst,
131 enum_return_check err_src,
132 enum_return_check err_dst,
133 const char **msg);
134 static bool init_repositories(Rpl_info *info, Rpl_info_handler **handler_src,
135 Rpl_info_handler **handler_dst,
136 const char **msg);
137 /**
138 Scan table and files for repositories.
139 If both file and table repositories are found an error is returned.
140 This method returns the number of repository instances found which
141 might imply a table scan.
142
143 @param[out] found_instances the number of repo instances found
144 @param[out] found_rep_option what is the type of repo found (FILE or TABLE)
145 @param[in] table_data the data on the tables to scan
146 @param[in] file_data the data on the files to scan
147 @param[out] msg the error message returned
148
149 @return true if an error occurs, false otherwise
150 */
151 static bool scan_and_count_repositories(ulonglong &found_instances,
152 uint &found_rep_option,
155 std::string &msg);
156 /**
157 Scan table and files for repositories.
158 If both file and table repositories are found an error is returned.
159 This method does not try to count the number of repositories, only
160 checks if they are present
161
162 @param[out] found_rep_option what is the type of repo found (FILE or TABLE)
163 @param[in] table_data the data on the tables to scan
164 @param[in] file_data the data on the files to scan
165 @param[out] msg the error message returned
166
167 @return true if an error occurs, false otherwise
168 */
169 static bool scan_and_check_repositories(uint &found_rep_option,
172 std::string &msg);
174 std::vector<std::string> &channel_list, uint mi_instances,
175 uint mi_repository, const char *default_channel,
176 bool *default_channel_created_previously);
177
179 std::vector<std::string> &channel_list, const char *default_channel,
180 bool *default_channel_created_previously);
181};
182
183#endif
Definition: rpl_mi.h:87
Class to store all the Master_info objects of a slave to access them in the replication code base or ...
Definition: rpl_msr.h:113
Definition: rpl_rli.h:203
Definition: rpl_info_factory.h:44
static struct_file_data worker_file_data
Definition: rpl_info_factory.h:114
static struct_table_data worker_table_data
Definition: rpl_info_factory.h:113
static Relay_log_info * create_rli(uint rli_option, bool is_slave_recovery, const char *channel, bool convert_repo)
Creates a Relay log info repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:206
static Master_info * create_mi(uint rli_option, const char *channel, bool conver_repo)
Creates a Master info repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:91
static bool change_rli_repository(Relay_log_info *rli, const uint rli_option, const char **msg)
Allows to change the relay log info repository after startup.
Definition: rpl_info_factory.cc:325
static bool create_slave_info_objects(uint mi_option, uint rli_option, int thread_mask, Multisource_info *pchannel_map)
This function should be called from init_replica() only.
Definition: rpl_info_factory.cc:1108
static bool load_channel_names_from_table(std::vector< std::string > &channel_list, const char *default_channel, bool *default_channel_created_previously)
In a multisourced slave, during init_replica(), the repositories are read to initialize the slave inf...
Definition: rpl_info_factory.cc:1354
static enum_return_check check_src_repository(Rpl_info *info, uint option, Rpl_info_handler **handler_src)
This method is called by the decide_repository() and is used to check if the source repository exits.
Definition: rpl_info_factory.cc:705
static bool change_mi_repository(Master_info *mi, const uint mi_option, const char **msg)
Allows to change the master info repository after startup.
Definition: rpl_info_factory.cc:161
static bool scan_and_count_repositories(ulonglong &found_instances, uint &found_rep_option, const struct_table_data &table_data, const struct_file_data &file_data, std::string &msg)
Scan table and files for repositories.
Definition: rpl_info_factory.cc:896
static void init_repository_metadata()
Initializes startup information on different repositories.
Definition: rpl_info_factory.cc:512
static void invalidate_repository_position(Master_info *mi)
If GTID_ONLY is set for this channel, receiver and applier positions will be marked as invalid.
Definition: rpl_info_factory.cc:1444
static struct_table_data mi_table_data
Definition: rpl_info_factory.h:111
static Slave_worker * create_worker(uint rli_option, uint worker_id, Relay_log_info *rli, bool is_gaps_collecting_phase)
Creates a Slave worker repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:416
static bool configure_channel_replication_filters(Relay_log_info *rli, const char *channel_name)
Establish the relation between the channel's replication filters and the channel's Relay_log_info,...
Definition: rpl_info_factory.cc:977
static bool init_repositories(const struct_table_data &table_data, const struct_file_data &file_data, uint option, Rpl_info_handler **handler_src, Rpl_info_handler **handler_dest, const char **msg)
Creates repositories that will be associated to either the Master_info or Relay_log_info.
Definition: rpl_info_factory.cc:842
static Master_info * create_mi_and_rli_objects(uint mi_option, uint rli_option, const char *channel, bool convert_repo, Multisource_info *channel_map)
Create Master_info and Relay_log_info objects for a new channel.
Definition: rpl_info_factory.cc:1245
static bool check_error_repository(Rpl_info_handler *handler_src, Rpl_info_handler *handler_dst, enum_return_check err_src, enum_return_check err_dst, const char **msg)
This method is called by the decide_repository() and is used print out information on errors.
Definition: rpl_info_factory.cc:765
static struct_table_data rli_table_data
Definition: rpl_info_factory.h:109
static struct_file_data mi_file_data
Definition: rpl_info_factory.h:112
static bool decide_repository(Rpl_info *info, uint option, Rpl_info_handler **handler_src, Rpl_info_handler **handler_dest, const char **msg)
Decides during startup what repository will be used based on the following decision table:
Definition: rpl_info_factory.cc:589
static bool reset_workers(Relay_log_info *rli)
Delete all info from Worker info tables to render them useless in future MTS recovery,...
Definition: rpl_info_factory.cc:359
static struct_file_data rli_file_data
Definition: rpl_info_factory.h:110
static bool load_channel_names_from_repository(std::vector< std::string > &channel_list, uint mi_instances, uint mi_repository, const char *default_channel, bool *default_channel_created_previously)
Make a list of any channels that may have existed on the previous slave run.
Definition: rpl_info_factory.cc:1300
static bool scan_and_check_repositories(uint &found_rep_option, const struct_table_data &table_data, const struct_file_data &file_data, std::string &msg)
Scan table and files for repositories.
Definition: rpl_info_factory.cc:939
struct Rpl_info_factory::table_data struct_table_data
struct Rpl_info_factory::file_data struct_file_data
Definition: rpl_info_handler.h:58
Definition: rpl_info.h:43
Definition: rpl_rli_pdb.h:498
void bitmap_free(MY_BITMAP *map)
Definition: my_bitmap.cc:158
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
Log info(cout, "NOTE")
ulong opt_mi_repository_id
Definition: sys_vars.cc:1713
ulong opt_rli_repository_id
Definition: sys_vars.cc:1723
enum_return_check
Definition: rpl_info_handler.h:51
Multisource_info channel_map
Definition: rpl_msr.cc:412
Definition: my_bitmap.h:43
Definition: rpl_info_factory.h:90
char name[FN_REFLEN]
Definition: rpl_info_factory.h:92
char pattern[FN_REFLEN]
Definition: rpl_info_factory.h:93
MY_BITMAP nullable_fields
Definition: rpl_info_factory.h:95
virtual ~file_data()
Definition: rpl_info_factory.h:96
uint n_fields
Definition: rpl_info_factory.h:91
bool name_indexed
Definition: rpl_info_factory.h:94
Definition: rpl_info_factory.h:99
virtual ~table_data()
Definition: rpl_info_factory.h:106
uint n_fields
Definition: rpl_info_factory.h:100
const char * schema
Definition: rpl_info_factory.h:101
const uint * pk_field_indexes
Definition: rpl_info_factory.h:104
const char * name
Definition: rpl_info_factory.h:102
MY_BITMAP nullable_fields
Definition: rpl_info_factory.h:105
uint n_pk_fields
Definition: rpl_info_factory.h:103
Definition: task.h:427
unsigned int uint
Definition: uca9-dump.cc:75