MySQL 26.7.0
Source Code Documentation
mysql::csa::Csa_service Class Reference

Service class for the Change Streams Applier (CSA) More...

#include <csa_service.h>

Inheritance diagram for mysql::csa::Csa_service:
[legend]

Public Types

using Task_result = mysql::scheduler::Task_result
 Result type for tasks. More...
 
using Thread_pool = mysql::scheduler::Thread_pool< Task_result, mysql::csa::tune::scheduler_tp_queue_size >
 Thread pool type. More...
 
using Thread_pool_ptr = std::shared_ptr< Thread_pool >
 Shared pointer to Thread_pool. More...
 
using Clock_type = mysql::scheduler::Clock_lwm_registry
 Clock type used in the scheduler. More...
 
using Clock_ptr = std::shared_ptr< mysql::scheduler::Scheduler_clock >
 Shared pointer to Scheduler_clock. More...
 
using Scheduler_type = mysql::scheduler::Scheduler
 Scheduler type. More...
 
using Scheduler_ptr = std::shared_ptr< Scheduler_type >
 Shared pointer to Scheduler_type. More...
 
using Schedule_factory = mysql::scheduler::Schedule_factory
 Schedule factory type. More...
 
using Schedule_factory_ptr = std::shared_ptr< Schedule_factory >
 Shared pointer to Schedule_factory. More...
 
using Dependency_tracker = mysql::scheduler::Dependency_tracker_stub
 Dependency tracker type. More...
 
using Dependency_tracker_ptr = mysql::scheduler::Dependency_tracker_ptr
 Shared pointer to Dependency_tracker. More...
 
using Session_service_ptr = mysql::csa::Session_service_ptr
 Shared pointer to Session_service. More...
 
using Sched_stat_map = mysql::scheduler::Statistics_map
 
using Commit_order_clock_type = mysql::scheduler::Commit_order_clock
 
- Public Types inherited from mysql::csa::Module
enum class  State { off = 0 , on , start , stop }
 Enum defining possible states of the module. More...
 
using Lock_guard = Lock_guard_object< Module >
 

Public Member Functions

 Csa_service ()
 Constructor. More...
 
virtual ~Csa_service () override
 Destructor. More...
 
bool run (Relay_log_info *rli)
 Synchronous method that runs the channel applier. More...
 
void remove (Relay_log_info *rli)
 Synchronous method that removes data and destroys objects related to the channel. More...
 
std::size_t get_workers_number (const char *channel)
 Obtains the number of workers configured for the channel. More...
 
std::optional< Session_legacy_statsget_session_legacy_stats (const char *channel, std::size_t worker_id)
 Obtains session legacy statistics kept in the RLI object. More...
 
std::optional< bool > has_applied_all_work (const char *channel)
 Checks whether applier for the channel has applied all of the work and is waiting for more tasks. More...
 
bool is_csa_event_applier (const char *channel, unsigned int thread_id)
 Checks whether CSA contains session with a given THD thread_id. More...
 
bool initialize_channel_data (const char *channel, std::size_t channel_unique_id, std::size_t worker_num)
 This function is used only to initialize channel legacy statistics and to make empty statistics available in case channel was not activated. More...
 
void clear_channel_data (const char *channel, bool remove)
 This function is used only to remove cached channel statistics upon channel deletion. More...
 
void stop (const char *channel, bool force_kill)
 Stops applier now. More...
 
- Public Member Functions inherited from mysql::csa::Module
 Module (PSI_mutex_key mutex_key, PSI_rwlock_key rwlock_key)
 Constructs the module. More...
 
virtual ~Module () override
 Destructor. More...
 
void init_locking ()
 Initializes internal locking. More...
 
bool init () override
 Initializes the module. More...
 
Lock_guard rdlock ()
 Acquires a read lock on this object. More...
 
Lock_guard wrlock ()
 Acquires a write lock on this object. More...
 
bool deinit () override
 Deinitializes the module. More...
 
bool is_inited ()
 Checks if the module is initialized. More...
 
- Public Member Functions inherited from mysql::csa::Initable
virtual ~Initable ()=default
 Destructor. More...
 

Private Member Functions

std::optional< Session_legacy_statsget_session_legacy_stats_internal (const char *channel, std::size_t worker_id)
 Obtains session legacy statistics kept in the RLI object, no lock. More...
 
bool do_init () override
 Initialization. More...
 
bool do_deinit () override
 Deinitialization. More...
 
void clean_up_context (const std::string &channel)
 Helper function to clean up channel data upon destruction. More...
 

Private Attributes

unsigned int m_kernel_ref_count {0}
 The number of references (channels), protected with internal lock. More...
 
std::unordered_map< std::string, Csa_channelcsa_channels
 Channel data. More...
 
std::unordered_map< std::string, std::vector< Session_legacy_stats > > m_inactive_channel_stats
 Cached statistics for inactive channels. More...
 
std::atomic< bool > m_soft_stop {false}
 When true, channels will execute soft stop after stop of the channel was requested. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mysql::csa::Module
void unlock ()
 Unlocks this module. More...
 

Detailed Description

Service class for the Change Streams Applier (CSA)

Member Typedef Documentation

◆ Clock_ptr

Shared pointer to Scheduler_clock.

◆ Clock_type

◆ Commit_order_clock_type

◆ Dependency_tracker

◆ Dependency_tracker_ptr

◆ Sched_stat_map

◆ Schedule_factory

◆ Schedule_factory_ptr

Shared pointer to Schedule_factory.

◆ Scheduler_ptr

Shared pointer to Scheduler_type.

◆ Scheduler_type

◆ Session_service_ptr

◆ Task_result

◆ Thread_pool

◆ Thread_pool_ptr

Shared pointer to Thread_pool.

Constructor & Destructor Documentation

◆ Csa_service()

mysql::csa::Csa_service::Csa_service ( )

Constructor.

◆ ~Csa_service()

mysql::csa::Csa_service::~Csa_service ( )
overridevirtual

Destructor.

Member Function Documentation

◆ clean_up_context()

void mysql::csa::Csa_service::clean_up_context ( const std::string &  channel)
private

Helper function to clean up channel data upon destruction.

Parameters
channelChannel identifier

◆ clear_channel_data()

void mysql::csa::Csa_service::clear_channel_data ( const char *  channel,
bool  remove 
)

This function is used only to remove cached channel statistics upon channel deletion.

Parameters
channelChannel name
removeWhen true, erases channel data. Otherwise, clears values.

◆ do_deinit()

bool mysql::csa::Csa_service::do_deinit ( )
overrideprivatevirtual

Deinitialization.

Return values
0Success
1Failure

Reimplemented from mysql::csa::Module.

◆ do_init()

bool mysql::csa::Csa_service::do_init ( )
overrideprivatevirtual

Initialization.

Return values
0Success
1Failure

Reimplemented from mysql::csa::Module.

◆ get_session_legacy_stats()

std::optional< Session_legacy_stats > mysql::csa::Csa_service::get_session_legacy_stats ( const char *  channel,
std::size_t  worker_id 
)

Obtains session legacy statistics kept in the RLI object.

Parameters
channelChannel id
worker_idId of the worker for which we want to extract the session
Returns
Upon success, returns corresponding legacy stats. If they are unavailable due to e.g. channel reconfiguration, returns an empty object

◆ get_session_legacy_stats_internal()

std::optional< Session_legacy_stats > mysql::csa::Csa_service::get_session_legacy_stats_internal ( const char *  channel,
std::size_t  worker_id 
)
private

Obtains session legacy statistics kept in the RLI object, no lock.

Parameters
channelChannel id
worker_idId of the worker for which we want to extract the session
Returns
Upon success, returns corresponding legacy stats. If they are unavailable due to e.g. channel reconfiguration, returns an empty object

◆ get_workers_number()

std::size_t mysql::csa::Csa_service::get_workers_number ( const char *  channel)

Obtains the number of workers configured for the channel.

◆ has_applied_all_work()

std::optional< bool > mysql::csa::Csa_service::has_applied_all_work ( const char *  channel)

Checks whether applier for the channel has applied all of the work and is waiting for more tasks.

Parameters
channelApplier channel name
Returns
When true - channel is waiting for more work. When false - channel is currently applying. When no value - no channel or channel is inactive

◆ initialize_channel_data()

bool mysql::csa::Csa_service::initialize_channel_data ( const char *  channel,
std::size_t  channel_unique_id,
std::size_t  worker_num 
)

This function is used only to initialize channel legacy statistics and to make empty statistics available in case channel was not activated.

Parameters
channelChannel name
channel_unique_idChannel unique integer identifier
worker_numWorkers number currently configured for this channel
Returns
True on success, false on failure

◆ is_csa_event_applier()

bool mysql::csa::Csa_service::is_csa_event_applier ( const char *  channel,
unsigned int  thread_id 
)

Checks whether CSA contains session with a given THD thread_id.

Parameters
channelSelected channel
thread_idTHD thread identifier

◆ remove()

void mysql::csa::Csa_service::remove ( Relay_log_info rli)

Synchronous method that removes data and destroys objects related to the channel.

Parameters
rliChannel RLI object

◆ run()

bool mysql::csa::Csa_service::run ( Relay_log_info rli)

Synchronous method that runs the channel applier.

Parameters
rliChannel RLI object
Returns
True if run succeeds, false otherwise

◆ stop()

void mysql::csa::Csa_service::stop ( const char *  channel,
bool  force_kill 
)

Stops applier now.

Parameters
channelChannel name
force_killWhen true, awakes all sessions

No more retries for transactions, applier is stopping

Member Data Documentation

◆ csa_channels

std::unordered_map<std::string, Csa_channel> mysql::csa::Csa_service::csa_channels
private

Channel data.

◆ m_inactive_channel_stats

std::unordered_map<std::string, std::vector<Session_legacy_stats> > mysql::csa::Csa_service::m_inactive_channel_stats
private

Cached statistics for inactive channels.

◆ m_kernel_ref_count

unsigned int mysql::csa::Csa_service::m_kernel_ref_count {0}
private

The number of references (channels), protected with internal lock.

◆ m_soft_stop

std::atomic<bool> mysql::csa::Csa_service::m_soft_stop {false}
private

When true, channels will execute soft stop after stop of the channel was requested.


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