MySQL 9.1.0
Source Code Documentation
cs::apply::instruments::Applier_metrics_interface Class Referenceabstract

This abstract class is an interface for classes that contain replication applier data as counters and wait times. More...

#include <applier_metrics_interface.h>

Inheritance diagram for cs::apply::instruments::Applier_metrics_interface:
[legend]

Public Member Functions

virtual ~Applier_metrics_interface ()=default
 
virtual void start_applier_timer ()=0
 Starts the timer when the applier metrics collection began. More...
 
virtual void stop_applier_timer ()=0
 Calculates the total time the applier ran. More...
 
virtual int64_t get_last_applier_start_micros () const =0
 Gets the time point when the metric timer started. More...
 
virtual int64_t get_total_execution_time () const =0
 Returns the total time the applier was running. More...
 
virtual void inc_transactions_committed_count (int64_t amount)=0
 increment the number of transactions committed. More...
 
virtual int64_t get_transactions_committed_count () const =0
 Gets the number of transactions committed. More...
 
virtual void inc_transactions_received_count (int64_t amount)=0
 increment the number of transactions received. More...
 
virtual int64_t get_transactions_received_count () const =0
 Gets the number of transactions received. More...
 
virtual void inc_transactions_committed_size_sum (int64_t amount)=0
 increment the size of transactions committed. More...
 
virtual int64_t get_transactions_committed_size_sum () const =0
 Gets the total sum of the size of committed transactions. More...
 
virtual void inc_transactions_received_size_sum (int64_t amount)=0
 increment the pending size of queued transactions. More...
 
virtual int64_t get_transactions_received_size_sum () const =0
 Gets the pending size sum of queued transactions. More...
 
virtual void inc_events_committed_count (int64_t amount)=0
 increment the number of events scheduled by a given amount. More...
 
virtual int64_t get_events_committed_count () const =0
 Gets the number of events scheduled. More...
 
virtual void reset ()=0
 Resets the statistics to zero. More...
 
virtual bool is_after_metrics_breakpoint () const =0
 Query whether the size/count of received transactions has been completely computed. More...
 
virtual void set_metrics_breakpoint (const char *relay_log_filename)=0
 If the metrics breakpoint has not been set yet, set it to the given filename. More...
 
virtual void check_metrics_breakpoint (const char *relay_log_filename)=0
 If the metrics breakpoint has been set and is equal to the given filename, remember that we are now after the metrics breakpoint, so that subsequent calls to is_after_metrics_breakpoint return true. More...
 
virtual Time_based_metric_interfaceget_work_from_source_wait_metric ()=0
 Returns time metrics for waits on work from the source. More...
 
virtual Time_based_metric_interfaceget_workers_available_wait_metric ()=0
 Returns time metrics for waits on available workers. More...
 
virtual Time_based_metric_interfaceget_transaction_dependency_wait_metric ()=0
 Returns time metrics for waits on transaction dependecies on workers. More...
 
virtual Time_based_metric_interfaceget_worker_queues_memory_exceeds_max_wait_metric ()=0
 Returns time metrics for waits when a worker queue exceeds max memory. More...
 
virtual Time_based_metric_interfaceget_worker_queues_full_wait_metric ()=0
 Returns time metrics for waits when the worker queues are full. More...
 
virtual Time_based_metric_interfaceget_time_to_read_from_relay_log_metric ()=0
 Returns time metrics for relay log read wait times. More...
 
virtual void inc_commit_order_wait_stored_metrics (int64_t count, int64_t time)=0
 Increments the stored values for the commit order metrics. More...
 
virtual int64_t get_number_of_waits_on_commit_order () const =0
 Gets the stored number of times we waited on committed order. More...
 
virtual int64_t get_wait_time_on_commit_order () const =0
 Gets the stored summed time waited on commit order. More...
 

Detailed Description

This abstract class is an interface for classes that contain replication applier data as counters and wait times.

Constructor & Destructor Documentation

◆ ~Applier_metrics_interface()

virtual cs::apply::instruments::Applier_metrics_interface::~Applier_metrics_interface ( )
virtualdefault

Member Function Documentation

◆ check_metrics_breakpoint()

virtual void cs::apply::instruments::Applier_metrics_interface::check_metrics_breakpoint ( const char *  relay_log_filename)
pure virtual

If the metrics breakpoint has been set and is equal to the given filename, remember that we are now after the metrics breakpoint, so that subsequent calls to is_after_metrics_breakpoint return true.

This function must only be called by the coordinator thread.

See also
is_after_metrics_breakpoint.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_events_committed_count()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_events_committed_count ( ) const
pure virtual

Gets the number of events scheduled.

Returns
the number of events scheduled.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_last_applier_start_micros()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_last_applier_start_micros ( ) const
pure virtual

Gets the time point when the metric timer started.

Returns
The time point since the collection of statistics started.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_number_of_waits_on_commit_order()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_number_of_waits_on_commit_order ( ) const
pure virtual

Gets the stored number of times we waited on committed order.

Returns
the stored number of commit order waits

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_time_to_read_from_relay_log_metric()

virtual Time_based_metric_interface & cs::apply::instruments::Applier_metrics_interface::get_time_to_read_from_relay_log_metric ( )
pure virtual

Returns time metrics for relay log read wait times.

Returns
a Time_based_metric_interface object that contains metric information on a wait

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_total_execution_time()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_total_execution_time ( ) const
pure virtual

Returns the total time the applier was running.

Returns
Amount of time the applier threads were running for this channel

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_transaction_dependency_wait_metric()

virtual Time_based_metric_interface & cs::apply::instruments::Applier_metrics_interface::get_transaction_dependency_wait_metric ( )
pure virtual

Returns time metrics for waits on transaction dependecies on workers.

Returns
a Time_based_metric_interface object that contains metric information on a wait

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_transactions_committed_count()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_transactions_committed_count ( ) const
pure virtual

Gets the number of transactions committed.

Returns
the number of transactions committed.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_transactions_committed_size_sum()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_transactions_committed_size_sum ( ) const
pure virtual

Gets the total sum of the size of committed transactions.

Returns
the total size of committed transactions

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_transactions_received_count()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_transactions_received_count ( ) const
pure virtual

Gets the number of transactions received.

Returns
the number of transactions received.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_transactions_received_size_sum()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_transactions_received_size_sum ( ) const
pure virtual

Gets the pending size sum of queued transactions.

Returns
the exectuted size of pending transactions

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_wait_time_on_commit_order()

virtual int64_t cs::apply::instruments::Applier_metrics_interface::get_wait_time_on_commit_order ( ) const
pure virtual

Gets the stored summed time waited on commit order.

Returns
the stored sum of the time waited on commit

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_work_from_source_wait_metric()

virtual Time_based_metric_interface & cs::apply::instruments::Applier_metrics_interface::get_work_from_source_wait_metric ( )
pure virtual

Returns time metrics for waits on work from the source.

Returns
a Time_based_metric_interface object that contains metric information on a wait

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_worker_queues_full_wait_metric()

virtual Time_based_metric_interface & cs::apply::instruments::Applier_metrics_interface::get_worker_queues_full_wait_metric ( )
pure virtual

Returns time metrics for waits when the worker queues are full.

Returns
a Time_based_metric_interface object that contains metric information on a wait

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_worker_queues_memory_exceeds_max_wait_metric()

virtual Time_based_metric_interface & cs::apply::instruments::Applier_metrics_interface::get_worker_queues_memory_exceeds_max_wait_metric ( )
pure virtual

Returns time metrics for waits when a worker queue exceeds max memory.

Returns
a Time_based_metric_interface object that contains metric information on a wait

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ get_workers_available_wait_metric()

virtual Time_based_metric_interface & cs::apply::instruments::Applier_metrics_interface::get_workers_available_wait_metric ( )
pure virtual

Returns time metrics for waits on available workers.

Returns
a Time_based_metric_interface object that contains metric information on a wait

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ inc_commit_order_wait_stored_metrics()

virtual void cs::apply::instruments::Applier_metrics_interface::inc_commit_order_wait_stored_metrics ( int64_t  count,
int64_t  time 
)
pure virtual

Increments the stored values for the commit order metrics.

Parameters
countThe count for commit order waits
timeThe time waited on commit order

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ inc_events_committed_count()

virtual void cs::apply::instruments::Applier_metrics_interface::inc_events_committed_count ( int64_t  amount)
pure virtual

increment the number of events scheduled by a given amount.

Parameters
amountthe amount of events to increment.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ inc_transactions_committed_count()

virtual void cs::apply::instruments::Applier_metrics_interface::inc_transactions_committed_count ( int64_t  amount)
pure virtual

increment the number of transactions committed.

Parameters
amountthe amount of transactions to increment.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ inc_transactions_committed_size_sum()

virtual void cs::apply::instruments::Applier_metrics_interface::inc_transactions_committed_size_sum ( int64_t  amount)
pure virtual

increment the size of transactions committed.

Parameters
amountthe size amount to increment.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ inc_transactions_received_count()

virtual void cs::apply::instruments::Applier_metrics_interface::inc_transactions_received_count ( int64_t  amount)
pure virtual

increment the number of transactions received.

Parameters
amountthe amount of transactions to increment.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ inc_transactions_received_size_sum()

virtual void cs::apply::instruments::Applier_metrics_interface::inc_transactions_received_size_sum ( int64_t  amount)
pure virtual

increment the pending size of queued transactions.

Parameters
amountthe size amount to increment.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ is_after_metrics_breakpoint()

virtual bool cs::apply::instruments::Applier_metrics_interface::is_after_metrics_breakpoint ( ) const
pure virtual

Query whether the size/count of received transactions has been completely computed.

Among other things, we track track the count and size of pending transactions, i.e., the transactions that are received but not yet committed. Internally, in this class, we track these metrics using two sets of transactions: the size/count of committed transactions and the size/count of received transactions. The size/count of pending transactions can be computed as the difference between the two.

The correct initial value for the received transactions would be the size of all not yet applied transactions in the relay log. To get that metric correct at the time the server starts (or the time the user enables collecting metrics), we would have to scan the relay logs. But that can be too expensive. So instead we just take a note that the metric is not yet known. Until the metric is known, we display the value as NULL to the user. Internally, we compute the initial value progressively, while applying those transactions.

We define the metrics breakpoint as the point in the relay log such that when the point is reached we know that the size/count of received transactions is completely computed. The metrics breakpoint is (the start of) the first relay log the receiver writes to.

Sizes/counts of transactions which appear before the metrics breakpoint are incremented when those transactions commit. When the metrics breakpoint is reached, the coordinator waits for preceding transactions to commit, and then declares that the metrics have been computed. Sizes/counts of transactions which appear after the metrics breakpoint are incremented when those transactions are fully received and written to the relay log.

When the receiver starts, it uses set_metrics_breakpoint to set the metric breakpoint to the relay log in which it writes the first event.

It is guaranteed that the applier, when it reaches first relay log that was received after the receiver thread started, waits for preceding transactions to complete. It does this while applying the Format_description_log_event from the source. Therefore, after any such wait, it uses check_metrics_breakpoint to checks if the current relay log is the metrics breakpoint. If that is the case, the internal flag m_is_after_metrics_breakpoint is set to true, and this makes subsequent calls to is_after_metrics_breakpoint return true.

When the coordinator schedules an event to a worker, it propagates is_after_metrics_breakpoint to the worker, through Slave_job_item::m_is_after_metrics_breakpoint. When the worker commits the transaction, it checks the flag. If the flag is false, it increments the count/size of received transactions.

This function may be called from many different threads.

Returns
true if the size/count of received transactions is initialized, false otherwise.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ reset()

virtual void cs::apply::instruments::Applier_metrics_interface::reset ( )
pure virtual

◆ set_metrics_breakpoint()

virtual void cs::apply::instruments::Applier_metrics_interface::set_metrics_breakpoint ( const char *  relay_log_filename)
pure virtual

If the metrics breakpoint has not been set yet, set it to the given filename.

This function must only be called by the receiver thread.

See also
is_after_metrics_breakpoint.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ start_applier_timer()

virtual void cs::apply::instruments::Applier_metrics_interface::start_applier_timer ( )
pure virtual

Starts the timer when the applier metrics collection began.

Sets the state to running. This can be queried later to know for how long time the stats have been collected, i.e., the duration.

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.

◆ stop_applier_timer()

virtual void cs::apply::instruments::Applier_metrics_interface::stop_applier_timer ( )
pure virtual

Calculates the total time the applier ran.

Sets the state to not running Sums to time since start to the total running time

Implemented in cs::apply::instruments::Applier_metrics, and cs::apply::instruments::Applier_metrics_stub.


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