MySQL 9.0.0
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
42 public:
43 static bool create_slave_info_objects(uint mi_option, uint rli_option,
44 int thread_mask,
45 Multisource_info *pchannel_map);
46
47 /**
48 Establish the relation between the channel's replication filters and
49 the channel's Relay_log_info, and copy global replication filters to
50 the channel's replication filters if needed.
51
52 @param rli Pointer to Relay_log_info.
53 @param channel_name The channel name.
54
55 @retval false No error
56 @retval true Failure
57 */
59 const char *channel_name);
60
61 static Master_info *create_mi_and_rli_objects(uint mi_option, uint rli_option,
62 const char *channel,
64
65 static Master_info *create_mi(uint rli_option, const char *channel);
66 static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery,
67 const char *channel);
68 static Slave_worker *create_worker(uint rli_option, uint worker_id,
69 Relay_log_info *rli,
70 bool is_gaps_collecting_phase);
71 static bool reset_workers(Relay_log_info *rli);
72 /**
73 If GTID_ONLY is set for this channel, receiver and applier positions
74 will be marked as invalid.
75
76 @param mi the repository info object whose positions will be invalidated
77 */
79
80 private:
81 typedef struct table_data {
83 const char *schema;
84 const char *name;
86 const uint *pk_field_indexes;
90
94
95 static void init_repository_metadata();
96
97 static bool init_repository(const struct_table_data &table_data, uint option,
99
100 static bool init_repository(Rpl_info *info, Rpl_info_handler **handler);
101 /**
102 Scan table for repositories.
103 This method returns the number of repository instances found which
104 might imply a table scan.
105
106 @param[out] found_instances the number of repo instances found
107 @param[out] found_rep_option what is the type of repo found
108 @param[in] table_data the data on the tables to scan
109
110 @return true if an error occurs, false otherwise
111 */
112 static bool scan_and_count_repositories(ulonglong &found_instances,
113 uint &found_rep_option,
115 /**
116 Scan table for repositories.
117 This method does not try to count the number of repositories, only
118 checks if they are present
119
120 @param[out] found_rep_option what is the type of repo found
121 @param[in] table_data the data on the tables to scan
122
123 @return true if an error occurs, false otherwise
124 */
125 static bool scan_and_check_repositories(uint &found_rep_option,
128 std::vector<std::string> &channel_list, uint mi_instances,
129 uint mi_repository, const char *default_channel,
130 bool *default_channel_created_previously);
131
133 std::vector<std::string> &channel_list, const char *default_channel,
134 bool *default_channel_created_previously);
135};
136
137#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:41
static struct_table_data worker_table_data
Definition: rpl_info_factory.h:93
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:574
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:695
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:85
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:794
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:486
static void init_repository_metadata()
Initializes startup information on different repositories.
Definition: rpl_info_factory.cc:384
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:884
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:462
static struct_table_data mi_table_data
Definition: rpl_info_factory.h:92
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:308
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:505
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:435
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:160
static struct_table_data rli_table_data
Definition: rpl_info_factory.h:91
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:256
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:749
struct Rpl_info_factory::table_data struct_table_data
Definition: rpl_info_handler.h:58
Definition: rpl_info.h:43
Definition: rpl_rli_pdb.h:498
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4573
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.
Multisource_info channel_map
Definition: rpl_msr.cc:418
Definition: my_bitmap.h:43
Definition: rpl_info_factory.h:81
virtual ~table_data()
Definition: rpl_info_factory.h:88
uint n_fields
Definition: rpl_info_factory.h:82
const char * schema
Definition: rpl_info_factory.h:83
const uint * pk_field_indexes
Definition: rpl_info_factory.h:86
const char * name
Definition: rpl_info_factory.h:84
MY_BITMAP nullable_fields
Definition: rpl_info_factory.h:87
uint n_pk_fields
Definition: rpl_info_factory.h:85
Definition: task.h:427