MySQL 8.0.40
Source Code Documentation
Rpl_info_factory Class Reference

#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_infocreate_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_infocreate_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_infocreate_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_workercreate_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
 

Member Typedef Documentation

◆ struct_file_data

◆ struct_table_data

Member Function Documentation

◆ change_mi_repository()

bool Rpl_info_factory::change_mi_repository ( Master_info mi,
const uint  mi_option,
const char **  msg 
)
static

Allows to change the master info repository after startup.

Parameters
[in]miReference to Master_info.
[in]mi_optionType of the repository, e.g. FILE TABLE.
[out]msgError message if something goes wrong.
Return values
falseNo error
trueFailure

◆ change_rli_repository()

bool Rpl_info_factory::change_rli_repository ( Relay_log_info rli,
const uint  rli_option,
const char **  msg 
)
static

Allows to change the relay log info repository after startup.

Parameters
[in]rliPointer to Relay_log_info.
[in]rli_optionType of the repository, e.g. FILE TABLE.
[out]msgError message if something goes wrong.
Return values
falseNo error
trueFailure

◆ check_error_repository()

bool Rpl_info_factory::check_error_repository ( Rpl_info_handler handler_src,
Rpl_info_handler handler_dest,
enum_return_check  err_src,
enum_return_check  err_dst,
const char **  msg 
)
staticprivate

This method is called by the decide_repository() and is used print out information on errors.

Parameters
handler_srcSource repository from where information is copied into the destination repository.
handler_destDestination repository to where information is copied.
err_srcPossible error status of the source repo check
err_dstPossible error status of the destination repo check
[out]msgError message if something goes wrong.
Return values
trueFailure

◆ check_src_repository()

enum_return_check Rpl_info_factory::check_src_repository ( Rpl_info info,
uint  option,
Rpl_info_handler **  handler_src 
)
staticprivate

This method is called by the decide_repository() and is used to check if the source repository exits.

Parameters
[in]infoEither master info or relay log info.
[in]optionIdentifies the type of the repository that will be used, i.e., destination repository.
[out]handler_srcSource repository from where information is
Returns
enum_return_check The repository's status.

◆ configure_channel_replication_filters()

bool Rpl_info_factory::configure_channel_replication_filters ( Relay_log_info rli,
const char *  channel_name 
)
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.

Parameters
rliPointer to Relay_log_info.
channel_nameThe channel name.
Return values
falseNo error
trueFailure

◆ create_mi()

Master_info * Rpl_info_factory::create_mi ( uint  mi_option,
const char *  channel,
bool  to_decide_repo 
)
static

Creates a Master info repository whose type is defined as a parameter.

Parameters
[in]mi_optionType of the repository, e.g. FILE TABLE.
[in]channelthe channel for which mi is to be created
[in]to_decide_repothe 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.

Return values
Pointerto Master_info Success
NULLFailure

◆ create_mi_and_rli_objects()

Master_info * Rpl_info_factory::create_mi_and_rli_objects ( uint  mi_option,
uint  rli_option,
const char *  channel,
bool  to_decide_repo,
Multisource_info pchannel_map 
)
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.

Parameters
[in]mi_optionmaster info repository
[in]rli_optionrelay log info repository
[in]channelthe channel for which these objects should be created.
[in]to_decide_repoFor this channel, check if repositories are allowed to convert from one type to other.
[in]pchannel_mapa pointer to channel_map
Returns
Pointer pointer to the created Master_info
NULL when creation fails

◆ create_rli()

Relay_log_info * Rpl_info_factory::create_rli ( uint  rli_option,
bool  is_slave_recovery,
const char *  channel,
bool  to_decide_repo 
)
static

Creates a Relay log info repository whose type is defined as a parameter.

Parameters
[in]rli_optionType of the Relay log info repository
[in]is_slave_recoveryIf the slave should try to start a recovery process to get consistent relay log files
[in]channelthe channel for which mi is to be created
[in]to_decide_repoIf 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.

Return values
Pointerto Relay_log_info Success
NULLFailure

◆ create_slave_info_objects()

bool Rpl_info_factory::create_slave_info_objects ( uint  mi_option,
uint  rli_option,
int  thread_mask,
Multisource_info pchannel_map 
)
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.

Some points to note from the above table

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.

Note
: only for type A) i.e default channel, it is permissible to have different repo types for Master_info and Relay_log_info (Ex: FILE for mi and TABLE for rli)
: The above restrictions break factory pattern in the code which has been followed throughout before.
: All the repository conversion(or live migration) functions (ex: decide_repository()) take Rpl_info::internal_id as an identifier which is always 1 for the case of Master_info and Relay_log_info. So, in the case of multisource replication, the decision to convert the repositories shall be made even before invoking decide_repository(). In other words, if a channel is not a default channel('') we shall not invoke decide_repository().
: In general, the algorithm in creation of slave info object is: l1: new slave_info; l2: Initialize the repository handlers l3: if (default_channel) check and convert repositories else TABLE type repository set the value of PK in the TABLE handler.
: Update from 5.6 to 5.7(which has Channel_Name in slave_info_tables) is handled in the upgrade script as usual.
Parameters
[in]mi_optionthe user provided master_info_repository
[in]rli_optionthe user provided relay_log_info_repository
[in]thread_maskthread mask
[in]pchannel_mapthe pointer to the multi source map (see, rpl_msr.h)
Return values
falsesuccess
truefail

◆ create_worker()

Slave_worker * Rpl_info_factory::create_worker ( uint  rli_option,
uint  worker_id,
Relay_log_info rli,
bool  is_gaps_collecting_phase 
)
static

Creates a Slave worker repository whose type is defined as a parameter.

Parameters
[in]rli_optionType of the repository, e.g. FILE TABLE.
[in]worker_idID of the worker to be created.
[in]rliPointer to Relay_log_info.
[in]is_gaps_collecting_phaseSee 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.

Return values
Pointerto Slave_worker Success
NULLFailure

◆ decide_repository()

bool Rpl_info_factory::decide_repository ( Rpl_info info,
uint  option,
Rpl_info_handler **  handler_src,
Rpl_info_handler **  handler_dest,
const char **  msg 
)
staticprivate

Decides during startup what repository will be used based on the following decision table:

|--------------+-----------------------+-----------------------|
| Exists \ Opt | SOURCE | DESTINATION |
|--------------+-----------------------+-----------------------|
| ~is_s, ~is_d | - | Create/Update D |
| ~is_s, is_d | - | Continue with D |
| is_s, ~is_d | Copy S into D | Create/Update D |
| is_s, is_d | Error | Error |
|--------------+-----------------------+-----------------------|
Class representing an error.
Definition: error.h:48
static handler * Create(handlerton *hton, TABLE_SHARE *table_share, bool, MEM_ROOT *mem_root)
Definition: ha_mock.cc:352
constexpr key_type Continue
Definition: http_request.h:52
Parameters
[in]infoEither master info or relay log info.
[in]optionIdentifies the type of the repository that will be used, i.e., destination repository.
[out]handler_srcSource repository from where information is copied into the destination repository.
[out]handler_destDestination repository to where information is copied.
[out]msgError message if something goes wrong.
Return values
falseNo error
trueFailure

◆ init_repositories() [1/2]

bool Rpl_info_factory::init_repositories ( const struct_table_data table_data,
const struct_file_data file_data,
uint  rep_option,
Rpl_info_handler **  handler_src,
Rpl_info_handler **  handler_dest,
const char **  msg 
)
staticprivate

Creates repositories that will be associated to either the Master_info or Relay_log_info.

Parameters
[in]table_dataDefines information to create a table repository.
[in]file_dataDefines information to create a file repository.
[in]rep_optionIdentifies the type of the repository that will be used, i.e., destination repository.
[out]handler_srcSource repository from where information is copied into the destination repository.
[out]handler_destDestination repository to where information is copied.
[out]msgError message if something goes wrong.
Return values
falseNo error
trueFailure

◆ init_repositories() [2/2]

bool Rpl_info_factory::init_repositories ( Rpl_info info,
Rpl_info_handler **  handler_src,
Rpl_info_handler **  handler_dest,
const char **  msg 
)
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.

Parameters
[in]infoEither master info or relay log info.
[out]handler_srcSource repository from where information is copied into the destination repository.
[out]handler_destDestination repository to where information is copied.
[out]msgError message if something goes wrong.
Return values
falseNo error
trueFailure

◆ init_repository_metadata()

void Rpl_info_factory::init_repository_metadata ( )
staticprivate

Initializes startup information on different repositories.

◆ invalidate_repository_position()

void Rpl_info_factory::invalidate_repository_position ( Master_info mi)
static

If GTID_ONLY is set for this channel, receiver and applier positions will be marked as invalid.

Parameters
mithe repository info object whose positions will be invalidated

◆ load_channel_names_from_repository()

bool Rpl_info_factory::load_channel_names_from_repository ( std::vector< std::string > &  channel_list,
uint  mi_instances,
uint  mi_repository,
const char *  default_channel,
bool *  default_channel_existed_previously 
)
staticprivate

Make a list of any channels that may have existed on the previous slave run.

Parameters
[out]channel_listthe names of all channels that exist on this slave.
[in]mi_instancesnumber of master_info repositories
[in]mi_repositoryFound master_info repository
[in]default_channelpointer to default channel.
[out]default_channel_existed_previouslyValue filled with true if default channel existed previously. False if it is not.
Return values
truefail
falsesuccess

◆ load_channel_names_from_table()

bool Rpl_info_factory::load_channel_names_from_table ( std::vector< std::string > &  channel_list,
const char *  default_channel,
bool *  default_channel_existed_previously 
)
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.

Parameters
[out]channel_listA reference to the channel list. This will be filled after reading the master info table, row by row.
[in]default_channelpointer to default channel.
[out]default_channel_existed_previouslyValue filled with true if default channel existed previously. False if it is not.

◆ reset_workers()

bool Rpl_info_factory::reset_workers ( Relay_log_info rli)
static

Delete all info from Worker info tables to render them useless in future MTS recovery, and indicate that in Coordinator info table.

Return values
falseon success
truewhen a failure in deletion or writing to Coordinator table fails.

◆ scan_and_check_repositories()

bool Rpl_info_factory::scan_and_check_repositories ( uint found_rep_option,
const struct_table_data table_data,
const struct_file_data file_data,
std::string &  msg 
)
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

Parameters
[out]found_rep_optionwhat is the type of repo found (FILE or TABLE)
[in]table_datathe data on the tables to scan
[in]file_datathe data on the files to scan
[out]msgthe error message returned
Returns
true if an error occurs, false otherwise

◆ scan_and_count_repositories()

bool Rpl_info_factory::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 
)
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.

Parameters
[out]found_instancesthe number of repo instances found
[out]found_rep_optionwhat is the type of repo found (FILE or TABLE)
[in]table_datathe data on the tables to scan
[in]file_datathe data on the files to scan
[out]msgthe error message returned
Returns
true if an error occurs, false otherwise

Member Data Documentation

◆ mi_file_data

Rpl_info_factory::struct_file_data Rpl_info_factory::mi_file_data
staticprivate

◆ mi_table_data

Rpl_info_factory::struct_table_data Rpl_info_factory::mi_table_data
staticprivate

◆ rli_file_data

Rpl_info_factory::struct_file_data Rpl_info_factory::rli_file_data
staticprivate

◆ rli_table_data

Rpl_info_factory::struct_table_data Rpl_info_factory::rli_table_data
staticprivate

◆ worker_file_data

Rpl_info_factory::struct_file_data Rpl_info_factory::worker_file_data
staticprivate

◆ worker_table_data

Rpl_info_factory::struct_table_data Rpl_info_factory::worker_table_data
staticprivate

The documentation for this class was generated from the following files: