MySQL 8.0.30
Source Code Documentation
rpl_info_factory.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2022, 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 RPL_INFO_FACTORY_H
24#define RPL_INFO_FACTORY_H
25
26#include <sys/types.h>
27#include <string>
28#include <vector>
29
30#include "my_bitmap.h"
31#include "my_io.h"
32#include "sql/rpl_info_handler.h" // enum_return_check
33
34class Master_info;
36class Relay_log_info;
37class Rpl_info;
38class Slave_worker;
39
40extern ulong opt_mi_repository_id;
41extern ulong opt_rli_repository_id;
42
44 public:
45 static bool create_slave_info_objects(uint mi_option, uint rli_option,
46 int thread_mask,
47 Multisource_info *pchannel_map);
48
49 /**
50 Establish the relation between the channel's replication filters and
51 the channel's Relay_log_info, and copy global replication filters to
52 the channel's replication filters if needed.
53
54 @param rli Pointer to Relay_log_info.
55 @param channel_name The channel name.
56
57 @retval false No error
58 @retval true Failure
59 */
61 const char *channel_name);
62
63 static Master_info *create_mi_and_rli_objects(uint mi_option, uint rli_option,
64 const char *channel,
65 bool convert_repo,
67
68 static Master_info *create_mi(uint rli_option, const char *channel,
69 bool conver_repo);
70 static bool change_mi_repository(Master_info *mi, const uint mi_option,
71 const char **msg);
72 static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery,
73 const char *channel, bool convert_repo);
74 static bool change_rli_repository(Relay_log_info *rli, const uint rli_option,
75 const char **msg);
76 static Slave_worker *create_worker(uint rli_option, uint worker_id,
77 Relay_log_info *rli,
78 bool is_gaps_collecting_phase);
79 static bool reset_workers(Relay_log_info *rli);
80 /**
81 If GTID_ONLY is set for this channel, receiver and applier positions
82 will be marked as invalid.
83
84 @param mi the repository info object whose positions will be invalidated
85 */
87
88 private:
89 typedef struct file_data {
93 bool name_indexed; // whether file name should include instance number
97
98 typedef struct table_data {
100 const char *schema;
101 const char *name;
107
114
115 static void init_repository_metadata();
116 static bool decide_repository(Rpl_info *info, uint option,
117 Rpl_info_handler **handler_src,
118 Rpl_info_handler **handler_dest,
119 const char **msg);
121 const struct_file_data &file_data, uint option,
122 Rpl_info_handler **handler_src,
123 Rpl_info_handler **handler_dest,
124 const char **msg);
125
127 Rpl_info_handler **handler_src);
128 static bool check_error_repository(Rpl_info_handler *handler_src,
129 Rpl_info_handler *handler_dst,
130 enum_return_check err_src,
131 enum_return_check err_dst,
132 const char **msg);
133 static bool init_repositories(Rpl_info *info, Rpl_info_handler **handler_src,
134 Rpl_info_handler **handler_dst,
135 const char **msg);
136 /**
137 Scan table and files for repositories.
138 If both file and table repositories are found an error is returned.
139 This method returns the number of repository instances found which
140 might imply a table scan.
141
142 @param[out] found_instances the number of repo instances found
143 @param[out] found_rep_option what is the type of repo found (FILE or TABLE)
144 @param[in] table_data the data on the tables to scan
145 @param[in] file_data the data on the files to scan
146 @param[out] msg the error message returned
147
148 @return true if an error occurs, false otherwise
149 */
150 static bool scan_and_count_repositories(ulonglong &found_instances,
151 uint &found_rep_option,
154 std::string &msg);
155 /**
156 Scan table and files for repositories.
157 If both file and table repositories are found an error is returned.
158 This method does not try to count the number of repositories, only
159 checks if they are present
160
161 @param[out] found_rep_option what is the type of repo found (FILE or TABLE)
162 @param[in] table_data the data on the tables to scan
163 @param[in] file_data the data on the files to scan
164 @param[out] msg the error message returned
165
166 @return true if an error occurs, false otherwise
167 */
168 static bool scan_and_check_repositories(uint &found_rep_option,
171 std::string &msg);
173 std::vector<std::string> &channel_list, uint mi_instances,
174 uint mi_repository, const char *default_channel,
175 bool *default_channel_created_previously);
176
178 std::vector<std::string> &channel_list, const char *default_channel,
179 bool *default_channel_created_previously);
180};
181
182#endif
Definition: rpl_mi.h:86
Class to store all the Master_info objects of a slave to access them in the replication code base or ...
Definition: rpl_msr.h:112
Definition: rpl_rli.h:201
Definition: rpl_info_factory.h:43
static struct_file_data worker_file_data
Definition: rpl_info_factory.h:113
static struct_table_data worker_table_data
Definition: rpl_info_factory.h:112
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:204
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:90
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:323
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:1105
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:1350
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:702
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:160
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:893
static void init_repository_metadata()
Initializes startup information on different repositories.
Definition: rpl_info_factory.cc:509
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:1439
static struct_table_data mi_table_data
Definition: rpl_info_factory.h:110
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:413
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:974
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:839
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:1241
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:762
static struct_table_data rli_table_data
Definition: rpl_info_factory.h:108
static struct_file_data mi_file_data
Definition: rpl_info_factory.h:111
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:586
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:357
static struct_file_data rli_file_data
Definition: rpl_info_factory.h:109
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:1296
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:936
struct Rpl_info_factory::table_data struct_table_data
struct Rpl_info_factory::file_data struct_file_data
Definition: rpl_info_handler.h:57
Definition: rpl_info.h:42
Definition: rpl_rli_pdb.h:497
void bitmap_free(MY_BITMAP *map)
Definition: my_bitmap.cc:157
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:82
Log info(cout, "NOTE")
ulong opt_mi_repository_id
Definition: sys_vars.cc:1695
ulong opt_rli_repository_id
Definition: sys_vars.cc:1705
enum_return_check
Definition: rpl_info_handler.h:50
Multisource_info channel_map
Definition: rpl_msr.cc:411
Definition: my_bitmap.h:42
Definition: rpl_info_factory.h:89
char name[FN_REFLEN]
Definition: rpl_info_factory.h:91
char pattern[FN_REFLEN]
Definition: rpl_info_factory.h:92
MY_BITMAP nullable_fields
Definition: rpl_info_factory.h:94
virtual ~file_data()
Definition: rpl_info_factory.h:95
uint n_fields
Definition: rpl_info_factory.h:90
bool name_indexed
Definition: rpl_info_factory.h:93
Definition: rpl_info_factory.h:98
virtual ~table_data()
Definition: rpl_info_factory.h:105
uint n_fields
Definition: rpl_info_factory.h:99
const char * schema
Definition: rpl_info_factory.h:100
const uint * pk_field_indexes
Definition: rpl_info_factory.h:103
const char * name
Definition: rpl_info_factory.h:101
MY_BITMAP nullable_fields
Definition: rpl_info_factory.h:104
uint n_pk_fields
Definition: rpl_info_factory.h:102
Definition: task.h:426
unsigned int uint
Definition: uca-dump.cc:29