MySQL 8.0.39
Source Code Documentation
|
#include <rpl_info_factory.h>
Classes | |
struct | file_data |
struct | table_data |
Static Public Member Functions | |
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. More... | |
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, and copy global replication filters to the channel's replication filters if needed. More... | |
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. More... | |
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. More... | |
static bool | change_mi_repository (Master_info *mi, const uint mi_option, const char **msg) |
Allows to change the master info repository after startup. More... | |
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. More... | |
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. More... | |
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. More... | |
static bool | reset_workers (Relay_log_info *rli) |
Delete all info from Worker info tables to render them useless in future MTS recovery, and indicate that in Coordinator info table. More... | |
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. More... | |
Private Types | |
typedef struct Rpl_info_factory::file_data | struct_file_data |
typedef struct Rpl_info_factory::table_data | struct_table_data |
Static Private Member Functions | |
static void | init_repository_metadata () |
Initializes startup information on different repositories. More... | |
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: More... | |
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. More... | |
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. More... | |
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. More... | |
static bool | init_repositories (Rpl_info *info, Rpl_info_handler **handler_src, Rpl_info_handler **handler_dst, const char **msg) |
This method is called by the decide_repository() and is used to initialize the repositories through a low-level interfacei, which means that if they do not exist nothing will be created. More... | |
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. More... | |
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. More... | |
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. More... | |
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 info objects. More... | |
Static Private Attributes | |
static struct_table_data | rli_table_data |
static struct_file_data | rli_file_data |
static struct_table_data | mi_table_data |
static struct_file_data | mi_file_data |
static struct_table_data | worker_table_data |
static struct_file_data | worker_file_data |
|
private |
|
private |
|
static |
Allows to change the master info repository after startup.
[in] | mi | Reference to Master_info. |
[in] | mi_option | Type of the repository, e.g. FILE TABLE. |
[out] | msg | Error message if something goes wrong. |
false | No error |
true | Failure |
|
static |
Allows to change the relay log info repository after startup.
[in] | rli | Pointer to Relay_log_info. |
[in] | rli_option | Type of the repository, e.g. FILE TABLE. |
[out] | msg | Error message if something goes wrong. |
false | No error |
true | Failure |
|
staticprivate |
This method is called by the decide_repository() and is used print out information on errors.
handler_src | Source repository from where information is copied into the destination repository. | |
handler_dest | Destination repository to where information is copied. | |
err_src | Possible error status of the source repo check | |
err_dst | Possible error status of the destination repo check | |
[out] | msg | Error message if something goes wrong. |
true | Failure |
|
staticprivate |
This method is called by the decide_repository() and is used to check if the source repository exits.
[in] | info | Either master info or relay log info. |
[in] | option | Identifies the type of the repository that will be used, i.e., destination repository. |
[out] | handler_src | Source repository from where information is |
|
static |
Establish the relation between the channel's replication filters and the channel's Relay_log_info, and copy global replication filters to the channel's replication filters if needed.
rli | Pointer to Relay_log_info. |
channel_name | The channel name. |
false | No error |
true | Failure |
|
static |
Creates a Master info repository whose type is defined as a parameter.
[in] | mi_option | Type of the repository, e.g. FILE TABLE. |
[in] | channel | the channel for which mi is to be created |
[in] | to_decide_repo | the flag is set to true if mi repositories are allowed to convert. For details, see init_replica() |
The execution fails if a user requests a type but a different type already exists in the system. This is done to avoid that a user accidentally accesses the wrong repository and makes the slave go out of sync.
Pointer | to Master_info Success |
NULL | Failure |
|
static |
Create Master_info and Relay_log_info objects for a new channel.
Also, set cross dependencies between these objects used all over the code.
Both master_info and relay_log_info repositories should be of the type TABLE. We do a check for this here as well.
[in] | mi_option | master info repository |
[in] | rli_option | relay log info repository |
[in] | channel | the channel for which these objects should be created. |
[in] | to_decide_repo | For this channel, check if repositories are allowed to convert from one type to other. |
[in] | pchannel_map | a pointer to channel_map |
|
static |
Creates a Relay log info repository whose type is defined as a parameter.
[in] | rli_option | Type of the Relay log info repository |
[in] | is_slave_recovery | If the slave should try to start a recovery process to get consistent relay log files |
[in] | channel | the channel for which mi is to be created |
[in] | to_decide_repo | If true, rli repositories are allowed to convert from one repo to other |
The execution fails if a user requests a type but a different type already exists in the system. This is done to avoid that a user accidentally accesses the wrong repository and make the slave go out of sync.
Pointer | to Relay_log_info Success |
NULL | Failure |
|
static |
This function should be called from init_replica() only.
During the server start, read all the slave repositories on disk (either in FILE or TABLE form) and create corresponding slave info objects. Each thus created master_info object is added to pchannel_map.
Multisource replication is supported by only TABLE based repositories. Based on this fact, the following table shows the supported cases considering the repository type and multiple channels of a slave. Each <—> represents a channel with a name on top of it. '' is an empty stringed channel (or default channel). 'N' indicates some name for a channel.
+--------------------------—+---------------—+--------—+ | channels | Supported? FILE | TABLE | +--------------------------—+---------------—+--------—+ | '' | | |
A) Master<----—>Slave | YES | YES |
---|---|---|
'N' | ||
B) Master<----—>Slave | NO | YES |
'' | ||
Master0<---------—+ | ||
'N' v | NO | YES |
C) Master1<--------—>Slave | ||
'N' ^ | ||
Mastern<---------—+ | ||
'N' | ||
Master1<---------—+ | ||
'N' v | NO | YES |
D) Master2<--------—>Slave | ||
'N' ^ | ||
Mastern<---------—+ | ||
+--------------------------—+---------------—+--------—+
In a new server, A) shown above is created by default. If there are multiple 'named' channels, but and if a default_channel is not created, it is created.
From the table it also follows that conversion of repositories is possible ONLY in the case of A) i.e for ex: if B) type repository (i.e a named slave channel) was found during server startup but the user repository option is INFO_REPOSITORY_FILE, then we exit the function.
[in] | mi_option | the user provided master_info_repository |
[in] | rli_option | the user provided relay_log_info_repository |
[in] | thread_mask | thread mask |
[in] | pchannel_map | the pointer to the multi source map (see, rpl_msr.h) |
false | success |
true | fail |
|
static |
Creates a Slave worker repository whose type is defined as a parameter.
[in] | rli_option | Type of the repository, e.g. FILE TABLE. |
[in] | worker_id | ID of the worker to be created. |
[in] | rli | Pointer to Relay_log_info. |
[in] | is_gaps_collecting_phase | See Slave_worker::rli_init_info |
The execution fails if a user requests a type but a different type already exists in the system. This is done to avoid that a user accidentally accesses the wrong repository and make the slave go out of sync.
Pointer | to Slave_worker Success |
NULL | Failure |
|
staticprivate |
Decides during startup what repository will be used based on the following decision table:
[in] | info | Either master info or relay log info. |
[in] | option | Identifies the type of the repository that will be used, i.e., destination repository. |
[out] | handler_src | Source repository from where information is copied into the destination repository. |
[out] | handler_dest | Destination repository to where information is copied. |
[out] | msg | Error message if something goes wrong. |
false | No error |
true | Failure |
|
staticprivate |
Creates repositories that will be associated to either the Master_info or Relay_log_info.
[in] | table_data | Defines information to create a table repository. |
[in] | file_data | Defines information to create a file repository. |
[in] | rep_option | Identifies the type of the repository that will be used, i.e., destination repository. |
[out] | handler_src | Source repository from where information is copied into the destination repository. |
[out] | handler_dest | Destination repository to where information is copied. |
[out] | msg | Error message if something goes wrong. |
false | No error |
true | Failure |
|
staticprivate |
This method is called by the decide_repository() and is used to initialize the repositories through a low-level interfacei, which means that if they do not exist nothing will be created.
[in] | info | Either master info or relay log info. |
[out] | handler_src | Source repository from where information is copied into the destination repository. |
[out] | handler_dest | Destination repository to where information is copied. |
[out] | msg | Error message if something goes wrong. |
false | No error |
true | Failure |
|
staticprivate |
Initializes startup information on different repositories.
|
static |
If GTID_ONLY is set for this channel, receiver and applier positions will be marked as invalid.
mi | the repository info object whose positions will be invalidated |
|
staticprivate |
Make a list of any channels that may have existed on the previous slave run.
[out] | channel_list | the names of all channels that exist on this slave. |
[in] | mi_instances | number of master_info repositories |
[in] | mi_repository | Found master_info repository |
[in] | default_channel | pointer to default channel. |
[out] | default_channel_existed_previously | Value filled with true if default channel existed previously. False if it is not. |
true | fail |
false | success |
|
staticprivate |
In a multisourced slave, during init_replica(), the repositories are read to initialize the slave info objects.
To initialize the slave info objects, we need the number of channels the slave was connected to previously. The following function, finds the number of channels in the master info repository. Later, this chanenl list is used to create a pair of {mi, rli} objects required for IO and SQL threads respectively.
[out] | channel_list | A reference to the channel list. This will be filled after reading the master info table, row by row. |
[in] | default_channel | pointer to default channel. |
[out] | default_channel_existed_previously | Value filled with true if default channel existed previously. False if it is not. |
|
static |
Delete all info from Worker info tables to render them useless in future MTS recovery, and indicate that in Coordinator info table.
false | on success |
true | when a failure in deletion or writing to Coordinator table fails. |
|
staticprivate |
Scan table and files for repositories.
If both file and table repositories are found an error is returned. This method does not try to count the number of repositories, only checks if they are present
[out] | found_rep_option | what is the type of repo found (FILE or TABLE) |
[in] | table_data | the data on the tables to scan |
[in] | file_data | the data on the files to scan |
[out] | msg | the error message returned |
|
staticprivate |
Scan table and files for repositories.
If both file and table repositories are found an error is returned. This method returns the number of repository instances found which might imply a table scan.
[out] | found_instances | the number of repo instances found |
[out] | found_rep_option | what is the type of repo found (FILE or TABLE) |
[in] | table_data | the data on the tables to scan |
[in] | file_data | the data on the files to scan |
[out] | msg | the error message returned |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |