MySQL 8.3.0
Source Code Documentation
rpl_info_factory.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 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 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
41 public:
42 static bool create_slave_info_objects(uint mi_option, uint rli_option,
43 int thread_mask,
44 Multisource_info *pchannel_map);
45
46 /**
47 Establish the relation between the channel's replication filters and
48 the channel's Relay_log_info, and copy global replication filters to
49 the channel's replication filters if needed.
50
51 @param rli Pointer to Relay_log_info.
52 @param channel_name The channel name.
53
54 @retval false No error
55 @retval true Failure
56 */
58 const char *channel_name);
59
60 static Master_info *create_mi_and_rli_objects(uint mi_option, uint rli_option,
61 const char *channel,
63
64 static Master_info *create_mi(uint rli_option, const char *channel);
65 static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery,
66 const char *channel);
67 static Slave_worker *create_worker(uint rli_option, uint worker_id,
68 Relay_log_info *rli,
69 bool is_gaps_collecting_phase);
70 static bool reset_workers(Relay_log_info *rli);
71 /**
72 If GTID_ONLY is set for this channel, receiver and applier positions
73 will be marked as invalid.
74
75 @param mi the repository info object whose positions will be invalidated
76 */
78
79 private:
80 typedef struct table_data {
82 const char *schema;
83 const char *name;
85 const uint *pk_field_indexes;
89
93
94 static void init_repository_metadata();
95
96 static bool init_repository(const struct_table_data &table_data, uint option,
98
100 /**
101 Scan table for repositories.
102 This method returns the number of repository instances found which
103 might imply a table scan.
104
105 @param[out] found_instances the number of repo instances found
106 @param[out] found_rep_option what is the type of repo found
107 @param[in] table_data the data on the tables to scan
108
109 @return true if an error occurs, false otherwise
110 */
111 static bool scan_and_count_repositories(ulonglong &found_instances,
112 uint &found_rep_option,
114 /**
115 Scan table for repositories.
116 This method does not try to count the number of repositories, only
117 checks if they are present
118
119 @param[out] found_rep_option what is the type of repo found
120 @param[in] table_data the data on the tables to scan
121
122 @return true if an error occurs, false otherwise
123 */
124 static bool scan_and_check_repositories(uint &found_rep_option,
127 std::vector<std::string> &channel_list, uint mi_instances,
128 uint mi_repository, const char *default_channel,
129 bool *default_channel_created_previously);
130
132 std::vector<std::string> &channel_list, const char *default_channel,
133 bool *default_channel_created_previously);
134};
135
136#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:202
Definition: rpl_info_factory.h:40
static struct_table_data worker_table_data
Definition: rpl_info_factory.h:92
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:573
static Master_info * create_mi_and_rli_objects(uint mi_option, uint rli_option, const char *channel, Multisource_info *channel_map)
Create Master_info and Relay_log_info objects for a new channel.
Definition: rpl_info_factory.cc:694
static Master_info * create_mi(uint rli_option, const char *channel)
Creates a Master info repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:84
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:793
static bool scan_and_check_repositories(uint &found_rep_option, const struct_table_data &table_data)
Scan table for repositories.
Definition: rpl_info_factory.cc:485
static void init_repository_metadata()
Initializes startup information on different repositories.
Definition: rpl_info_factory.cc:383
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:883
static bool scan_and_count_repositories(ulonglong &found_instances, uint &found_rep_option, const struct_table_data &table_data)
Scan table for repositories.
Definition: rpl_info_factory.cc:461
static struct_table_data mi_table_data
Definition: rpl_info_factory.h:91
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:307
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:504
static bool init_repository(const struct_table_data &table_data, uint option, Rpl_info_handler **handler)
Creates repositories that will be associated to either the Master_info or Relay_log_info.
Definition: rpl_info_factory.cc:434
static Relay_log_info * create_rli(uint rli_option, bool is_slave_recovery, const char *channel)
Creates a Relay log info repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:159
static struct_table_data rli_table_data
Definition: rpl_info_factory.h:90
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:255
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:748
struct Rpl_info_factory::table_data struct_table_data
Definition: rpl_info_handler.h:57
Definition: rpl_info.h:42
Definition: rpl_rli_pdb.h:497
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4548
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.
Multisource_info channel_map
Definition: rpl_msr.cc:411
Definition: my_bitmap.h:42
Definition: rpl_info_factory.h:80
virtual ~table_data()
Definition: rpl_info_factory.h:87
uint n_fields
Definition: rpl_info_factory.h:81
const char * schema
Definition: rpl_info_factory.h:82
const uint * pk_field_indexes
Definition: rpl_info_factory.h:85
const char * name
Definition: rpl_info_factory.h:83
MY_BITMAP nullable_fields
Definition: rpl_info_factory.h:86
uint n_pk_fields
Definition: rpl_info_factory.h:84
Definition: task.h:426