MySQL 9.1.0
Source Code Documentation
Rpl_channel_filters Class Reference

The class is a container for all the per-channel filters, both a map of Rpl_filter objects and a list of Rpl_pfs_filter objects. More...

#include <rpl_msr.h>

Public Member Functions

Rpl_filtercreate_filter (const char *channel_name)
 Create a new replication filter and add it into a filter map. More...
 
void delete_filter (Rpl_filter *rpl_filter)
 Delete the replication filter from the filter map. More...
 
void discard_all_unattached_filters ()
 Discard all replication filters if they are not attached to channels. More...
 
void discard_group_replication_filters ()
 discard filters on group replication channels. More...
 
Rpl_filterget_channel_filter (const char *channel_name)
 Get a replication filter of a channel. More...
 
void reset_pfs_view ()
 This member function is called every time a filter is created or deleted, or its filter rules are changed. More...
 
Rpl_pfs_filterget_filter_at_pos (uint pos)
 Used only by replication performance schema indices to get the replication filter at the position 'pos' from the rpl_pfs_filter_vec vector. More...
 
uint get_filter_count ()
 Used only by replication performance schema indices to get the count of replication filters from the rpl_pfs_filter_vec vector. More...
 
bool build_do_and_ignore_table_hashes ()
 Traverse the filter map, build do_table and ignore_table rules to hashes for every filter. More...
 
 Rpl_channel_filters ()
 
 ~Rpl_channel_filters ()
 
void clean_up ()
 Traverse the filter map and free all filters. More...
 
void wrlock ()
 Acquire the write lock. More...
 
void rdlock ()
 Acquire the read lock. More...
 
void unlock ()
 Release the lock (whether it is a write or read lock). More...
 

Private Attributes

filter_map channel_to_filter
 
std::vector< Rpl_pfs_filterrpl_pfs_filter_vec
 
Checkable_rwlockm_channel_to_filter_lock
 

Detailed Description

The class is a container for all the per-channel filters, both a map of Rpl_filter objects and a list of Rpl_pfs_filter objects.

It maintains a filter map which maps a replication filter to a channel name. Which is needed, because replication channels are not created and channel_map is not filled in when these global and per-channel replication filters are evaluated with current code frame. In theory, after instantiating all channels from the repository and throwing all the warnings about the filters configured for non-existent channels, we can forget about its global object rpl_channel_filters and rely only on the global and per channel Rpl_filter objects. But to avoid holding the channel_map.rdlock() when querying P_S.replication_applier_filters table, we keep the rpl_channel_filters. So that we just need to hold the small rpl_channel_filters.rdlock() when querying P_S.replication_applier_filters table. Many operations (RESET REPLICA [FOR CHANNEL], START REPLICA, INIT SLAVE, END SLAVE, CHANGE REPLICATION SOURCE TO, FLUSH RELAY LOGS, START CHANNEL, PURGE CHANNEL, and so on) hold the channel_map.wrlock().

There is one instance, rpl_channel_filters, created globally for Multisource channel filters. The rpl_channel_filters is created when the server is started, destroyed when the server is stopped.

Constructor & Destructor Documentation

◆ Rpl_channel_filters()

Rpl_channel_filters::Rpl_channel_filters ( )
inline

◆ ~Rpl_channel_filters()

Rpl_channel_filters::~Rpl_channel_filters ( )
inline

Member Function Documentation

◆ build_do_and_ignore_table_hashes()

bool Rpl_channel_filters::build_do_and_ignore_table_hashes ( )

Traverse the filter map, build do_table and ignore_table rules to hashes for every filter.

Return values
0OK
-1Error

◆ clean_up()

void Rpl_channel_filters::clean_up ( )
inline

Traverse the filter map and free all filters.

Delete all objects in the rpl_pfs_filter_vec vector and then clear the vector.

◆ create_filter()

Rpl_filter * Rpl_channel_filters::create_filter ( const char *  channel_name)

Create a new replication filter and add it into a filter map.

Parameters
channel_nameA name of a channel.
Return values
Rpl_filterA pointer to a replication filter, or NULL if we failed to add it into fiter_map.

◆ delete_filter()

void Rpl_channel_filters::delete_filter ( Rpl_filter rpl_filter)

Delete the replication filter from the filter map.

Parameters
rpl_filterA pointer to point to a replication filter.

◆ discard_all_unattached_filters()

void Rpl_channel_filters::discard_all_unattached_filters ( )

Discard all replication filters if they are not attached to channels.

◆ discard_group_replication_filters()

void Rpl_channel_filters::discard_group_replication_filters ( )

discard filters on group replication channels.

◆ get_channel_filter()

Rpl_filter * Rpl_channel_filters::get_channel_filter ( const char *  channel_name)

Get a replication filter of a channel.

Parameters
channel_nameA name of a channel.
Return values
Rpl_filterA pointer to a replication filter, or NULL if we failed to add a replication filter into fiter_map when creating it.

◆ get_filter_at_pos()

Rpl_pfs_filter * Rpl_channel_filters::get_filter_at_pos ( uint  pos)

Used only by replication performance schema indices to get the replication filter at the position 'pos' from the rpl_pfs_filter_vec vector.

Parameters
posthe index in the rpl_pfs_filter_vec vector.
Return values
Rpl_filterA pointer to a Rpl_pfs_filter, or NULL if it arrived the end of the rpl_pfs_filter_vec.

◆ get_filter_count()

uint Rpl_channel_filters::get_filter_count ( )

Used only by replication performance schema indices to get the count of replication filters from the rpl_pfs_filter_vec vector.

Return values
thecount of the replication filters.

◆ rdlock()

void Rpl_channel_filters::rdlock ( )
inline

Acquire the read lock.

◆ reset_pfs_view()

void Rpl_channel_filters::reset_pfs_view ( )

This member function is called every time a filter is created or deleted, or its filter rules are changed.

Once that happens the PFS view is recreated.

◆ unlock()

void Rpl_channel_filters::unlock ( )
inline

Release the lock (whether it is a write or read lock).

◆ wrlock()

void Rpl_channel_filters::wrlock ( )
inline

Acquire the write lock.

Member Data Documentation

◆ channel_to_filter

filter_map Rpl_channel_filters::channel_to_filter
private

◆ m_channel_to_filter_lock

Checkable_rwlock* Rpl_channel_filters::m_channel_to_filter_lock
private

◆ rpl_pfs_filter_vec

std::vector<Rpl_pfs_filter> Rpl_channel_filters::rpl_pfs_filter_vec
private

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