MySQL 8.4.3
Source Code Documentation
Rpl_info_factory Class Reference

#include <rpl_info_factory.h>

Classes

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, 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)
 Creates a Master info repository whose type is defined as a parameter. More...
 
static Relay_log_infocreate_rli (uint rli_option, bool is_slave_recovery, const char *channel)
 Creates a Relay log info repository whose type is defined as a parameter. 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::table_data struct_table_data
 

Static Private Member Functions

static void init_repository_metadata ()
 Initializes startup information on different repositories. More...
 
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. More...
 
static bool init_repository (Rpl_info *info, Rpl_info_handler **handler)
 This method is used to initialize the repositories through a low-level interface, 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)
 Scan table for repositories. More...
 
static bool scan_and_check_repositories (uint &found_rep_option, const struct_table_data &table_data)
 Scan table 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_table_data mi_table_data
 
static struct_table_data worker_table_data
 

Member Typedef Documentation

◆ struct_table_data

Member Function Documentation

◆ 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 
)
static

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

Parameters
[in]mi_optionType of the repository, e.g. TABLE.
[in]channelthe channel for which mi is to be created

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,
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]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 
)
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

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 replica repositories on disk and create corresponding Relay_log_info slave info objects. Each thus created object is added to pchannel_map.

In a new server, an empty-named channel for a replica-source connection is created by default. If there are multiple 'named' channels, but and if a default_channel is not created, it is created.

Note
: 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.
Parameters
[in]mi_optionthe user provided repository type for MI
[in]rli_optionthe user provided repository type for RLI
[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. 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

◆ init_repository() [1/2]

bool Rpl_info_factory::init_repository ( const struct_table_data table_data,
uint  rep_option,
Rpl_info_handler **  handler 
)
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]rep_optionIdentifies the type of the repository that will be used, i.e., destination repository.
[out]handlerDestination repository
Return values
falseNo error
trueFailure

◆ init_repository() [2/2]

bool Rpl_info_factory::init_repository ( Rpl_info info,
Rpl_info_handler **  handler 
)
staticprivate

This method is used to initialize the repositories through a low-level interface, which means that if they do not exist nothing will be created.

Parameters
[in]infoEither master info or relay log info.
[out]handlerRepository handler
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 
)
staticprivate

Scan table for repositories.

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
[in]table_datathe data on the tables to scan
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 
)
staticprivate

Scan table for repositories.

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
[in]table_datathe data on the tables to scan
Returns
true if an error occurs, false otherwise

Member Data Documentation

◆ mi_table_data

Rpl_info_factory::struct_table_data Rpl_info_factory::mi_table_data
staticprivate

◆ rli_table_data

Rpl_info_factory::struct_table_data Rpl_info_factory::rli_table_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: