![]() |
MySQL 26.10.0
Source Code Documentation
|
Memory Collector. More...
#include <health_monitor_memory.h>
Public Member Functions | |
| Memory_Collector () | |
| void | set_buffer_size () final |
| Resize the stat buffer if necessary. More... | |
| bool | settings_changed () override |
| Indicate if the Memory Collector settings have changed. More... | |
| void | set_params () final |
| Set collection parameters from the system variables. More... | |
| bool | running () const override |
| Return health_monitor.memory_running. More... | |
| std::shared_ptr< Stat_Buffer< Process_Memory_Info > > | proc_buffer () |
| std::shared_ptr< Stat_Buffer< System_Memory_Info > > | sys_buffer () |
| int | get_memory_info (Memory_Info &memory_info) |
| Get the current system and process memory info. More... | |
| int | get_process_memory_info (Process_Memory_Info &process_info, bool &unavailable) |
| Get the physical memory used by the current process. More... | |
| int | get_system_memory_info (System_Memory_Info &sys_memory_info) |
| Get memory stats for the system. More... | |
| void | update_per_sample_totals (const Memory_Info &memory_info) |
| Update totals used for status and warning messages, convert to MiB. More... | |
| void | set_memory_profile (const Memory_Info &memory_info) |
| Update the memory warning thresholds, convert to MiB. More... | |
| void | set_state (ms::Memory_State &new_state) |
| Set the next state based on the available memory. More... | |
| void | set_start_state () |
| void | set_stop_state () |
| void | set_normal_state () |
| void | set_warning_state () |
| void | set_error_state () |
| void | check_memory_levels () const |
| Check the available memory against the memory thresholds. More... | |
| void | log_resource_status () override |
| Memory status, depending on state. More... | |
| std::string | format_settings () override |
| Memory Collector settings formatted string. More... | |
| std::string | format_status_info () override |
| Memory info formatted string. More... | |
| std::string | tag_collector_state () override |
| Collector state tag. More... | |
| void | log_warning_level (int) |
| Low memory warning level 1/2/3. More... | |
| void | log_warning_level () |
| void | log_warning_error_condition () |
| Error condition warning. More... | |
Public Member Functions inherited from hm::Collector | |
| Collector ()=default | |
| Collector (const char *name, const char *resource_name, const char *instr_name, const char *os_name, const char *description) | |
| ~Collector () override=default | |
| Collector (const Collector &)=delete | |
| Collector & | operator= (const Collector &)=delete |
| Collector (Collector &&)=delete | |
| Collector & | operator= (Collector &&)=delete |
| const char * | resource_name () const |
| void | run_process () override |
| Sample collection loop. More... | |
| virtual bool | dynamic_settings_changed () |
| virtual bool | static_settings_changed () |
| void | mark_settings_pending () |
| Mark a settings update for evaluation by the Supervisor. More... | |
| bool | settings_pending () const |
| void | set_settings_pending (bool pending) |
| virtual bool | update_settings () |
| Update system variable settings for the Collector. More... | |
| int | base_interval () const |
| int | sample_interval () const |
| void | set_sample_interval (int sample_interval) |
| Set the sample interval, adjust to the nearest multiple of the base interval. More... | |
| void | set_collector_intervals (int base_interval, int sample_interval) |
| Set the base and sample intervals together to ensure that the sample interval is a multiple of the base interval. More... | |
| virtual void | log_collector_status (bool settings) |
| Collector status with optional settings. More... | |
| virtual void | log_collector_status (const std::string &state_msg, bool settings) |
| Collector status with optional message and optional settings. More... | |
| virtual void | log_status () |
| Issue a log status message for the collector. More... | |
| virtual void | log_resource_levels () |
| Log general resource status with state, mode (Fallback, Recovery, ...) and levels. More... | |
| virtual std::string | build_collector_message (const std::string &status, const std::string &mode, const std::string &message, bool settings) |
| Formatted collector message with optional settings. More... | |
| virtual std::string | build_resource_message (const std::string &status, const std::string &mode, const std::string &message, bool levels) |
| Formatted resource message, no levels or settings. More... | |
| virtual std::string | tag_resource_state () |
| virtual std::string | tag_mode () |
Public Member Functions inherited from hm::Thread | |
| Thread ()=default | |
| Thread (const char *name, const char *instr_name, const char *os_name, const char *desc) | |
| virtual | ~Thread ()=0 |
| const char * | name () const |
| virtual int | start () |
| virtual void | stop () |
| void | signal () |
| Signal the processing loop to end the current cycle. More... | |
Static Public Member Functions | |
| static void | set_state_params () |
| Set threshold params for all memory states. More... | |
Static Public Member Functions inherited from hm::Collector | |
| static std::string | format_level (uint64_t mbytes) |
| Format storage amount in MiB, no units. More... | |
| static std::string | format_mb (uint64_t mbytes, int prec, bool show_units) |
| Format storage amount. More... | |
Static Public Member Functions inherited from hm::Thread | |
| static void | cleanup () |
| Cleanup thread instrumentation. More... | |
| static int | join (my_thread_handle *thread, void **value_ptr) |
| static bool | joinable (const my_thread_handle &thread) |
Protected Member Functions | |
| void | pre_process () override |
| Tasks before starting the collection loop. More... | |
| void | process () override |
| Collect the current memory stats and write to the stat buffer. More... | |
| void | post_process () override |
| Final tasks before exiting the thread. More... | |
Protected Member Functions inherited from hm::Collector | |
| void | consume_settings_pending () |
| Consume one pending notification without clearing a concurrent update. More... | |
| void | apply_pending_settings () |
| Apply settings while the collector command lock is held. More... | |
| Cycle_Timer & | sample_timer () |
| Cycle_Timer & | status_message_timer () |
| void | initialize_sample_timers () |
| Initialize collection timers. More... | |
| void | advance_sample_timers () |
| Process collector sample and status timers. More... | |
Protected Member Functions inherited from hm::Thread | |
| int | start_thread () |
| void | stop_thread () |
| void | request_thread_stop () |
| Request that the worker stop without waiting for it to exit. More... | |
| void | join_thread () |
| Wait for a stopped worker to exit. More... | |
| bool | stop_requested () |
| Return true when worker shutdown has been requested. More... | |
Private Attributes | |
| std::shared_ptr< Stat_Buffer< Process_Memory_Info > > | m_proc_buffer |
| std::shared_ptr< Stat_Buffer< System_Memory_Info > > | m_sys_buffer |
| PSI_rwlock_key | m_rwlock_key {0} |
| PSI_rwlock_info | m_rwlock_info |
| PSI_memory_key | m_memory_key {0} |
| PSI_memory_info | m_memory_info |
Additional Inherited Members | |
Static Public Attributes inherited from hm::Collector | |
| static constexpr uint64_t | no_warn_level {std::numeric_limits<uint64_t>::max()} |
| static constexpr int | k_min_interval {1} |
| static constexpr int | k_max_interval {86400} |
| static constexpr int | k_default_base_interval {10} |
| static constexpr int | k_default_sample_interval {k_default_base_interval * 6} |
Protected Attributes inherited from hm::Collector | |
| const std::string | m_resource_name |
| bool | m_running {false} |
Protected Attributes inherited from hm::Thread | |
| std::mutex | m_command_lock |
| const std::string | m_name |
| const std::string | m_instr_name |
| const std::string | m_os_name |
| const std::string | m_description |
| std::atomic< bool > | m_thread_running {false} |
| bool | m_stop {false} |
| my_thread_handle | m_thread |
| PSI_thread_key | m_thread_key {0} |
| PSI_thread_info | m_thread_info |
| mysql_mutex_t | m_wait_lock |
| PSI_mutex_key | m_mutex_key {0} |
| PSI_mutex_info | m_mutex_info |
| mysql_cond_t | m_wait |
| PSI_cond_key | m_cond_key {0} |
| PSI_cond_info | m_cond_info |
Memory Collector.
The Memory Collector monitors server memory usage, publishes memory statistics, and emits warnings when available memory falls below the configured thresholds. Unlike the Disk Collector, the Memory Collector does not take corrective action when memory is low.
| hm::Memory_Collector::Memory_Collector | ( | ) |
| void hm::Memory_Collector::check_memory_levels | ( | ) | const |
Check the available memory against the memory thresholds.
If available space < any warning level, issue warning message. Otherwise issue a status message.
|
overridevirtual |
Memory Collector settings formatted string.
Reimplemented from hm::Collector.
|
overridevirtual |
Memory info formatted string.
Reimplemented from hm::Collector.
| int hm::Memory_Collector::get_memory_info | ( | Memory_Info & | memory_info | ) |
Get the current system and process memory info.
| [out] | memory_info | System and process memory info |
| int hm::Memory_Collector::get_process_memory_info | ( | Process_Memory_Info & | process_info, |
| bool & | unavailable | ||
| ) |
Get the physical memory used by the current process.
| [out] | process_info | Process memory info |
| [out] | unavailable | Whether the process memory API is unavailable |
| int hm::Memory_Collector::get_system_memory_info | ( | System_Memory_Info & | sys_memory_info | ) |
Get memory stats for the system.
| [out] | sys_memory_info | System memory info |
|
overridevirtual |
Memory status, depending on state.
Implements hm::Collector.
| void hm::Memory_Collector::log_warning_error_condition | ( | ) |
Error condition warning.
|
inline |
| void hm::Memory_Collector::log_warning_level | ( | int | ) |
Low memory warning level 1/2/3.
|
overrideprotectedvirtual |
Final tasks before exiting the thread.
Reimplemented from hm::Thread.
|
overrideprotectedvirtual |
Tasks before starting the collection loop.
Reimplemented from hm::Thread.
|
inline |
|
overrideprotectedvirtual |
Collect the current memory stats and write to the stat buffer.
Reimplemented from hm::Collector.
|
overridevirtual |
Return health_monitor.memory_running.
Reimplemented from hm::Thread.
|
finalvirtual |
Resize the stat buffer if necessary.
Must be inside collector lock.
Reimplemented from hm::Collector.
|
inline |
| void hm::Memory_Collector::set_memory_profile | ( | const Memory_Info & | memory_info | ) |
Update the memory warning thresholds, convert to MiB.
| [in] | memory_info | System memory info |
|
inline |
|
finalvirtual |
Set collection parameters from the system variables.
Reimplemented from hm::Collector.
|
inline |
| void hm::Memory_Collector::set_state | ( | ms::Memory_State & | new_state | ) |
Set the next state based on the available memory.
|
static |
Set threshold params for all memory states.
|
inline |
|
inline |
|
overridevirtual |
Indicate if the Memory Collector settings have changed.
Reimplemented from hm::Collector.
|
inline |
|
overridevirtual |
Collector state tag.
Reimplemented from hm::Collector.
| void hm::Memory_Collector::update_per_sample_totals | ( | const Memory_Info & | memory_info | ) |
Update totals used for status and warning messages, convert to MiB.
| [in] | memory_info | System memory info |
| const std::string hm::Memory_Collector::k_warning_level {"Warning Level"} |
| uint64_t hm::Memory_Collector::m_avail_mb {0} |
| ms::Memory_State* hm::Memory_Collector::m_current_state {nullptr} |
| int hm::Memory_Collector::m_delta_pct {10} |
| ms::Error_State hm::Memory_Collector::m_error_state |
| Memory_Info hm::Memory_Collector::m_info |
| uint64_t hm::Memory_Collector::m_last_avail_mb {0} |
| uint64_t hm::Memory_Collector::m_last_warn_level_mb {no_warn_level} |
| uint64_t hm::Memory_Collector::m_max_warn_level_mb {no_warn_level} |
|
private |
|
private |
| ms::Normal_State hm::Memory_Collector::m_normal_state |
|
private |
| uint64_t hm::Memory_Collector::m_process_mb {0} |
| bool hm::Memory_Collector::m_refresh_memory_profile {false} |
|
private |
|
private |
| std::atomic<bool> hm::Memory_Collector::m_settings_changed {false} |
| ms::Start_State hm::Memory_Collector::m_start_state |
| ms::Stop_State hm::Memory_Collector::m_stop_state |
|
private |
| bool hm::Memory_Collector::m_sysinfo_error {false} |
| uint64_t hm::Memory_Collector::m_total_mb {0} |
| float hm::Memory_Collector::m_used_pct {0} |
| uint64_t hm::Memory_Collector::m_warn_level_1_mb {0} |
| uint64_t hm::Memory_Collector::m_warn_level_2_mb {0} |
| uint64_t hm::Memory_Collector::m_warn_level_3_mb {0} |
| ms::Warning_State hm::Memory_Collector::m_warning_state |