MySQL 9.7.0
Source Code Documentation
gr_resource_manager::Resource_manager_stats_collector Class Reference

#include <resource_manager_stats_collector.h>

Public Member Functions

 Resource_manager_stats_collector ()
 
 ~Resource_manager_stats_collector ()
 
 Resource_manager_stats_collector (const Resource_manager_stats_collector &)=delete
 
Resource_manager_stats_collectoroperator= (const Resource_manager_stats_collector &)=delete
 
 Resource_manager_stats_collector (Resource_manager_stats_collector &&)=delete
 
Resource_manager_stats_collectoroperator= (Resource_manager_stats_collector &&)=delete
 
uint get_applier_lag ()
 Return applier lag. More...
 
uint get_recovery_lag ()
 Return recovery lag. More...
 
uint get_percentage_used_memory ()
 Return used memory. More...
 
uint get_applier_hit_number_of_times ()
 Returns number of times applier lag was seen. More...
 
uint get_recovery_hit_number_of_times ()
 Returns number of times recovery lag was seen. More...
 
uint get_memory_hit_number_of_times ()
 Returns number of times low memory was observed. More...
 
eject_status leave_group ()
 
bool is_group_replication_running () const
 Checks if group_replication is running. More...
 
bool is_group_in_single_primary_mode_and_im_a_secondary () const
 Checks if group is in single primary mode and secondary. More...
 
std::string get_applier_eviction_timestamp ()
 Timestamp of last eviction caused by applier lag. More...
 
std::string get_recovery_eviction_timestamp ()
 Timestamp of last eviction caused by recovery lag. More...
 
std::string get_memory_eviction_timestamp ()
 Timestamp of last eviction caused by low memory. More...
 
std::string get_lag_query_last_error_timestamp ()
 Timestamp of last channel lag query failure. More...
 
std::string get_memory_last_error_timestamp ()
 Timestamp of last memory status failure. More...
 
int start_thread ()
 Thread functions. More...
 
void stop_thread ()
 
void run_process ()
 

Static Public Member Functions

static bool is_time_diff_greater_than (uint64_t timepoint, uint64_t now, uint64_t diff=300)
 Check if the time difference between timepoint and now is greater than diff. More...
 
static uint64_t get_time_now_seconds ()
 Returns the current time represented by seconds elapsed since the Epoch. More...
 
static uint64_t get_time_now_microseconds ()
 Returns the current time represented by micro-seconds elapsed since the Epoch. More...
 
static std::string convert_microseconds_to_timestamp_string (uint64_t microseconds_since_epoch)
 Converts a time point represented by micro-seconds elapsed since the Epoch to the string format 'YYYY-MM-DD hh:mm:ss.ffffff'. More...
 

Private Types

enum  gr_rm_thread_state { IDLE , RUNNING , STOPPING }
 

Private Member Functions

int fetch_memory_used ()
 Wrappers to call API and do error handling. More...
 
int fetch_channel_lag ()
 
void process ()
 

Static Private Member Functions

static int join (my_thread_handle *thread, void **value_ptr)
 
static bool joinable (const my_thread_handle &thread)
 

Private Attributes

gr_resource_manager::Memory_Info m_memory_info
 
std::atomic< uint64_t > m_channel_lag_monitoring_error_timestamp {0}
 Timestamp of last channel lag query failure. More...
 
std::atomic< uint64_t > m_memory_monitoring_error_timestamp {0}
 Timestamp of last memory information failure. More...
 
uint m_applier_continuous_lag {0}
 Number of times applier channel lag was hit continuously. More...
 
uint m_recovery_continuous_lag {0}
 Number of times recovery channel lag was hit continuously. More...
 
uint m_memory_continuous_excess_usage {0}
 Number of times memory consumption cross the limit continuously. More...
 
std::atomic< uint > m_applier_lag_last_fetched {0}
 Below information is needed by status variables. More...
 
std::atomic< uint > m_recovery_lag_last_fetched {0}
 Recovery channel lag fetched from SQL Query. More...
 
std::atomic< uint > m_percentage_used_memory_last_fetched {0}
 Used memory in percentage fetched from system. More...
 
std::atomic< uint > m_applier_hit_number_of_times {0}
 Number of times applier channel lag exceeded the limit. More...
 
std::atomic< uint > m_recovery_hit_number_of_times {0}
 Number of times recovery channel lag exceeded the limit. More...
 
std::atomic< uint > m_memory_hit_number_of_times {0}
 Number of times memory comsuption exceeded the limit. More...
 
std::atomic< uint64_t > m_applier_eviction_timestamp {0}
 Last timestamp member left the group due to applier lag. More...
 
std::atomic< uint64_t > m_recovery_eviction_timestamp {0}
 Last timestamp member left the group due to recovery lag. More...
 
std::atomic< uint64_t > m_memory_eviction_timestamp {0}
 Last timestamp member left the group due to memory excessive consumption. More...
 
unsigned int m_seconds_since_member_join {0}
 Time difference in seconds between last time this member joined and now. More...
 
uint64_t m_not_removed_applier_threshold_hit_quarantime_ts_s {0}
 Below variables are needed to reduce the frequency of logging. More...
 
uint64_t m_not_removed_recovery_threshold_hit_quarantime_ts_s {0}
 
uint64_t m_not_removed_memory_threshold_hit_quarantime_ts_s {0}
 
uint64_t m_not_removed_applier_threshold_hit_n_members_ts_s {0}
 
uint64_t m_not_removed_recovery_threshold_hit_n_members_ts_s {0}
 
uint64_t m_not_removed_memory_threshold_hit_n_members_ts_s {0}
 
const std::string m_name
 Needed by THD. More...
 
const std::string m_instr_name
 
const std::string m_os_name
 
const std::string m_description
 
gr_rm_thread_state m_thread_state {IDLE}
 
my_thread_handle m_thread
 Thread structure. More...
 
PSI_thread_key m_thread_key {0}
 
PSI_thread_info m_thread_info
 
mysql_mutex_t m_command_lock
 Synchronize start, stop and update. More...
 
PSI_mutex_key m_command_key {0}
 
PSI_mutex_info m_command_info
 
mysql_cond_t m_wait
 
PSI_cond_key m_cond_key {0}
 
PSI_cond_info m_cond_info
 

Static Private Attributes

static constexpr uint s_sample_rate {5}
 frequency of sample collection, in seconds More...
 
static constexpr uint s_max_continuous_lag_counter {10}
 Continuous lag tolerance limit. More...
 

Member Enumeration Documentation

◆ gr_rm_thread_state

Enumerator
IDLE 
RUNNING 
STOPPING 

Constructor & Destructor Documentation

◆ Resource_manager_stats_collector() [1/3]

gr_resource_manager::Resource_manager_stats_collector::Resource_manager_stats_collector ( )

◆ ~Resource_manager_stats_collector()

gr_resource_manager::Resource_manager_stats_collector::~Resource_manager_stats_collector ( )

◆ Resource_manager_stats_collector() [2/3]

gr_resource_manager::Resource_manager_stats_collector::Resource_manager_stats_collector ( const Resource_manager_stats_collector )
delete

◆ Resource_manager_stats_collector() [3/3]

gr_resource_manager::Resource_manager_stats_collector::Resource_manager_stats_collector ( Resource_manager_stats_collector &&  )
delete

Member Function Documentation

◆ convert_microseconds_to_timestamp_string()

std::string gr_resource_manager::Resource_manager_stats_collector::convert_microseconds_to_timestamp_string ( uint64_t  microseconds_since_epoch)
static

Converts a time point represented by micro-seconds elapsed since the Epoch to the string format 'YYYY-MM-DD hh:mm:ss.ffffff'.

Parameters
[in]microseconds_since_epochtime point represented by micro-seconds elapsed since the Epoch
Returns
a string with the format 'YYYY-MM-DD hh:mm:ss.ffffff'

◆ fetch_channel_lag()

int gr_resource_manager::Resource_manager_stats_collector::fetch_channel_lag ( )
private

◆ fetch_memory_used()

int gr_resource_manager::Resource_manager_stats_collector::fetch_memory_used ( )
private

Wrappers to call API and do error handling.

◆ get_applier_eviction_timestamp()

std::string gr_resource_manager::Resource_manager_stats_collector::get_applier_eviction_timestamp ( )

Timestamp of last eviction caused by applier lag.

◆ get_applier_hit_number_of_times()

uint gr_resource_manager::Resource_manager_stats_collector::get_applier_hit_number_of_times ( )
inline

Returns number of times applier lag was seen.

Return values
counterof applier lag seen

◆ get_applier_lag()

uint gr_resource_manager::Resource_manager_stats_collector::get_applier_lag ( )

Return applier lag.

Return values
applierlag in seconds

◆ get_lag_query_last_error_timestamp()

std::string gr_resource_manager::Resource_manager_stats_collector::get_lag_query_last_error_timestamp ( )

Timestamp of last channel lag query failure.

◆ get_memory_eviction_timestamp()

std::string gr_resource_manager::Resource_manager_stats_collector::get_memory_eviction_timestamp ( )

Timestamp of last eviction caused by low memory.

◆ get_memory_hit_number_of_times()

uint gr_resource_manager::Resource_manager_stats_collector::get_memory_hit_number_of_times ( )
inline

Returns number of times low memory was observed.

Return values
counterof low memory seen

◆ get_memory_last_error_timestamp()

std::string gr_resource_manager::Resource_manager_stats_collector::get_memory_last_error_timestamp ( )

Timestamp of last memory status failure.

◆ get_percentage_used_memory()

uint gr_resource_manager::Resource_manager_stats_collector::get_percentage_used_memory ( )

Return used memory.

Return values
percentageof used memory

◆ get_recovery_eviction_timestamp()

std::string gr_resource_manager::Resource_manager_stats_collector::get_recovery_eviction_timestamp ( )

Timestamp of last eviction caused by recovery lag.

◆ get_recovery_hit_number_of_times()

uint gr_resource_manager::Resource_manager_stats_collector::get_recovery_hit_number_of_times ( )
inline

Returns number of times recovery lag was seen.

Return values
counterof recovery lag seen

◆ get_recovery_lag()

uint gr_resource_manager::Resource_manager_stats_collector::get_recovery_lag ( )

Return recovery lag.

Return values
recoverylag in seconds

◆ get_time_now_microseconds()

uint64_t gr_resource_manager::Resource_manager_stats_collector::get_time_now_microseconds ( )
static

Returns the current time represented by micro-seconds elapsed since the Epoch.

Returns
the current time represented by micro-seconds elapsed since the Epoch.

◆ get_time_now_seconds()

uint64_t gr_resource_manager::Resource_manager_stats_collector::get_time_now_seconds ( )
static

Returns the current time represented by seconds elapsed since the Epoch.

Returns
the current time represented by seconds elapsed since the Epoch.

◆ is_group_in_single_primary_mode_and_im_a_secondary()

bool gr_resource_manager::Resource_manager_stats_collector::is_group_in_single_primary_mode_and_im_a_secondary ( ) const

Checks if group is in single primary mode and secondary.

◆ is_group_replication_running()

bool gr_resource_manager::Resource_manager_stats_collector::is_group_replication_running ( ) const

Checks if group_replication is running.

◆ is_time_diff_greater_than()

bool gr_resource_manager::Resource_manager_stats_collector::is_time_diff_greater_than ( uint64_t  timepoint,
uint64_t  now,
uint64_t  diff = 300 
)
static

Check if the time difference between timepoint and now is greater than diff.

Parameters must be of the same unit: seconds, microseconds...

Parameters
[in]timepointtimepoint in time
[in]nowa later timepoint in time
[in]diffthe difference to compare
Returns
true time difference between timepoint and now is greater than diff false otherwise

◆ join()

int gr_resource_manager::Resource_manager_stats_collector::join ( my_thread_handle thread,
void **  value_ptr 
)
staticprivate

◆ joinable()

bool gr_resource_manager::Resource_manager_stats_collector::joinable ( const my_thread_handle thread)
staticprivate

◆ leave_group()

eject_status gr_resource_manager::Resource_manager_stats_collector::leave_group ( )

◆ operator=() [1/2]

Resource_manager_stats_collector & gr_resource_manager::Resource_manager_stats_collector::operator= ( const Resource_manager_stats_collector )
delete

◆ operator=() [2/2]

Resource_manager_stats_collector & gr_resource_manager::Resource_manager_stats_collector::operator= ( Resource_manager_stats_collector &&  )
delete

◆ process()

void gr_resource_manager::Resource_manager_stats_collector::process ( )
private

◆ run_process()

void gr_resource_manager::Resource_manager_stats_collector::run_process ( )

◆ start_thread()

int gr_resource_manager::Resource_manager_stats_collector::start_thread ( )

Thread functions.

◆ stop_thread()

void gr_resource_manager::Resource_manager_stats_collector::stop_thread ( )

Member Data Documentation

◆ m_applier_continuous_lag

uint gr_resource_manager::Resource_manager_stats_collector::m_applier_continuous_lag {0}
private

Number of times applier channel lag was hit continuously.

◆ m_applier_eviction_timestamp

std::atomic<uint64_t> gr_resource_manager::Resource_manager_stats_collector::m_applier_eviction_timestamp {0}
private

Last timestamp member left the group due to applier lag.

◆ m_applier_hit_number_of_times

std::atomic<uint> gr_resource_manager::Resource_manager_stats_collector::m_applier_hit_number_of_times {0}
private

Number of times applier channel lag exceeded the limit.

◆ m_applier_lag_last_fetched

std::atomic<uint> gr_resource_manager::Resource_manager_stats_collector::m_applier_lag_last_fetched {0}
private

Below information is needed by status variables.

Applier channel lag fetched from SQL Query.

◆ m_channel_lag_monitoring_error_timestamp

std::atomic<uint64_t> gr_resource_manager::Resource_manager_stats_collector::m_channel_lag_monitoring_error_timestamp {0}
private

Timestamp of last channel lag query failure.

◆ m_command_info

PSI_mutex_info gr_resource_manager::Resource_manager_stats_collector::m_command_info
private
Initial value:
const std::string m_instr_name
Definition: resource_manager_stats_collector.h:243
PSI_mutex_key m_command_key
Definition: resource_manager_stats_collector.h:263
#define PSI_DOCUMENT_ME
Definition: component_common.h:29
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:35
#define PSI_VOLATILITY_PROVISIONING
Definition: psi_bits.h:155

◆ m_command_key

PSI_mutex_key gr_resource_manager::Resource_manager_stats_collector::m_command_key {0}
private

◆ m_command_lock

mysql_mutex_t gr_resource_manager::Resource_manager_stats_collector::m_command_lock
private

Synchronize start, stop and update.

◆ m_cond_info

PSI_cond_info gr_resource_manager::Resource_manager_stats_collector::m_cond_info
private
Initial value:

◆ m_cond_key

PSI_cond_key gr_resource_manager::Resource_manager_stats_collector::m_cond_key {0}
private

◆ m_description

const std::string gr_resource_manager::Resource_manager_stats_collector::m_description
private

◆ m_instr_name

const std::string gr_resource_manager::Resource_manager_stats_collector::m_instr_name
private

◆ m_memory_continuous_excess_usage

uint gr_resource_manager::Resource_manager_stats_collector::m_memory_continuous_excess_usage {0}
private

Number of times memory consumption cross the limit continuously.

◆ m_memory_eviction_timestamp

std::atomic<uint64_t> gr_resource_manager::Resource_manager_stats_collector::m_memory_eviction_timestamp {0}
private

Last timestamp member left the group due to memory excessive consumption.

◆ m_memory_hit_number_of_times

std::atomic<uint> gr_resource_manager::Resource_manager_stats_collector::m_memory_hit_number_of_times {0}
private

Number of times memory comsuption exceeded the limit.

◆ m_memory_info

gr_resource_manager::Memory_Info gr_resource_manager::Resource_manager_stats_collector::m_memory_info
private

◆ m_memory_monitoring_error_timestamp

std::atomic<uint64_t> gr_resource_manager::Resource_manager_stats_collector::m_memory_monitoring_error_timestamp {0}
private

Timestamp of last memory information failure.

◆ m_name

const std::string gr_resource_manager::Resource_manager_stats_collector::m_name
private

Needed by THD.

◆ m_not_removed_applier_threshold_hit_n_members_ts_s

uint64_t gr_resource_manager::Resource_manager_stats_collector::m_not_removed_applier_threshold_hit_n_members_ts_s {0}
private

◆ m_not_removed_applier_threshold_hit_quarantime_ts_s

uint64_t gr_resource_manager::Resource_manager_stats_collector::m_not_removed_applier_threshold_hit_quarantime_ts_s {0}
private

Below variables are needed to reduce the frequency of logging.

◆ m_not_removed_memory_threshold_hit_n_members_ts_s

uint64_t gr_resource_manager::Resource_manager_stats_collector::m_not_removed_memory_threshold_hit_n_members_ts_s {0}
private

◆ m_not_removed_memory_threshold_hit_quarantime_ts_s

uint64_t gr_resource_manager::Resource_manager_stats_collector::m_not_removed_memory_threshold_hit_quarantime_ts_s {0}
private

◆ m_not_removed_recovery_threshold_hit_n_members_ts_s

uint64_t gr_resource_manager::Resource_manager_stats_collector::m_not_removed_recovery_threshold_hit_n_members_ts_s {0}
private

◆ m_not_removed_recovery_threshold_hit_quarantime_ts_s

uint64_t gr_resource_manager::Resource_manager_stats_collector::m_not_removed_recovery_threshold_hit_quarantime_ts_s {0}
private

◆ m_os_name

const std::string gr_resource_manager::Resource_manager_stats_collector::m_os_name
private

◆ m_percentage_used_memory_last_fetched

std::atomic<uint> gr_resource_manager::Resource_manager_stats_collector::m_percentage_used_memory_last_fetched {0}
private

Used memory in percentage fetched from system.

◆ m_recovery_continuous_lag

uint gr_resource_manager::Resource_manager_stats_collector::m_recovery_continuous_lag {0}
private

Number of times recovery channel lag was hit continuously.

◆ m_recovery_eviction_timestamp

std::atomic<uint64_t> gr_resource_manager::Resource_manager_stats_collector::m_recovery_eviction_timestamp {0}
private

Last timestamp member left the group due to recovery lag.

◆ m_recovery_hit_number_of_times

std::atomic<uint> gr_resource_manager::Resource_manager_stats_collector::m_recovery_hit_number_of_times {0}
private

Number of times recovery channel lag exceeded the limit.

◆ m_recovery_lag_last_fetched

std::atomic<uint> gr_resource_manager::Resource_manager_stats_collector::m_recovery_lag_last_fetched {0}
private

Recovery channel lag fetched from SQL Query.

◆ m_seconds_since_member_join

unsigned int gr_resource_manager::Resource_manager_stats_collector::m_seconds_since_member_join {0}
private

Time difference in seconds between last time this member joined and now.

◆ m_thread

my_thread_handle gr_resource_manager::Resource_manager_stats_collector::m_thread
private

Thread structure.

◆ m_thread_info

PSI_thread_info gr_resource_manager::Resource_manager_stats_collector::m_thread_info
private
Initial value:
{
m_instr_name.c_str(),
m_os_name.c_str(),
m_description.c_str()}
PSI_thread_key m_thread_key
Definition: resource_manager_stats_collector.h:252
const std::string m_description
Definition: resource_manager_stats_collector.h:245
const std::string m_os_name
Definition: resource_manager_stats_collector.h:244
#define PSI_FLAG_THREAD_SYSTEM
System thread flag.
Definition: psi_bits.h:124

◆ m_thread_key

PSI_thread_key gr_resource_manager::Resource_manager_stats_collector::m_thread_key {0}
private

◆ m_thread_state

gr_rm_thread_state gr_resource_manager::Resource_manager_stats_collector::m_thread_state {IDLE}
private

◆ m_wait

mysql_cond_t gr_resource_manager::Resource_manager_stats_collector::m_wait
private

◆ s_max_continuous_lag_counter

constexpr uint gr_resource_manager::Resource_manager_stats_collector::s_max_continuous_lag_counter {10}
staticconstexprprivate

Continuous lag tolerance limit.

◆ s_sample_rate

constexpr uint gr_resource_manager::Resource_manager_stats_collector::s_sample_rate {5}
staticconstexprprivate

frequency of sample collection, in seconds


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