MySQL 26.10.0
Source Code Documentation
health_monitor_disk.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2026, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#pragma once
25
26#include <optional>
27
35
36namespace hm {
37// clang-format off
38
39/**
40 Fallback State
41
42 "Fallback" is the process of fencing the server when disk space is critically
43 low. The Fallback_State class manages the state of the fallback process, such
44 as tracking whether the Health Monitor set or attempted to set SUPER_READ_ONLY
45 and/or OFFLINE_MODE.
46
47 The fallback state does not indicate the actual value of the system variables,
48 only whether or not the Health Monitor set them. This allows the Health
49 Monitor to detect when the system variables are changed externally and sync
50 with the server state.
51*/
53 public:
54 Fallback_State() = default;
55
56 void reset() {
61 m_force_attempted = false;
62 m_last_reason.clear();
63 m_last_state = nullptr;
64 }
65
66 void hard_reset() {
67 reset();
68 m_count = 0;
69 }
70
71 [[nodiscard]] bool enabled() const { return m_enabled; }
72 void set_enabled(bool value) { m_enabled = value; }
73
74 [[nodiscard]] bool force_enabled() const { return m_force_enabled; }
76
77 // The server is considered fenced if the Health Monitor set either
78 // SUPER_READ_ONLY or OFFLINE_MODE.
79 [[nodiscard]] bool fenced() const {
81 }
82
83 [[nodiscard]] bool offline_mode_was_set_by_hm() const { return m_offline_mode_was_set_by_hm; }
87 }
88
93 }
94
95 [[nodiscard]] bool super_read_only_retry_failed() const {
97 }
100 }
101
102 [[nodiscard]] bool super_read_only_force_failed() const {
104 }
107 }
108
109 [[nodiscard]] bool force_attempted() const { return m_force_attempted; }
111
112 [[nodiscard]] int count() const { return m_count; }
113 int &count() { return m_count; } // support ++/--
114 void set_count(int value) { m_count = value; }
115
116 std::string &last_reason() { return m_last_reason; } // support '='
117 [[nodiscard]] const std::string &last_reason() const { return m_last_reason; }
118 void set_last_reason(const std::string &value) { m_last_reason = value; }
119
120 [[nodiscard]] const ds::Storage_State *last_state() const { return m_last_state; }
122
123 private:
124 bool m_enabled{false}; // system variable 'disk_fallback_enable'
125 bool m_force_enabled{false}; // system variable 'disk_fallback_force_enable'
126 bool m_offline_mode_was_set_by_hm{false}; // true if the Health Monitor set OFFLINE_MODE
127 bool m_super_read_only_was_set_by_hm{false}; // true if the Health Monitor set SUPER_READ_ONLY
128 bool m_super_read_only_retry_failed{false}; // true if unable to set SUPER_READ_ONLY (unforced)
129 bool m_super_read_only_force_failed{false}; // true if unable to set SUPER_READ_ONLY (forced)
130 bool m_force_attempted{false}; // true if SUPER_READ_ONLY (forced) was attempted
131 std::string m_last_reason; // last reason why server is ineligible for fencing
132 ds::Storage_State *m_last_state{nullptr}; // last state the reason was printed
133 int m_count{0}; // the number of times the server was fenced
134};
135
136/**
137 Recovery State
138
139 "Recovery" is the process of unfencing the server and restoring normal
140 operating mode by setting SUPER_READ_ONLY = OFF and OFFLINE_MODE = OFF.
141 The recovery process is triggered when storage levels rise above the
142 configured recovery level after the server has been fenced.
143
144 The Recovery_State class manages the state of the recovery process, such as
145 tracking the recovery timers and the number of recovery cycles.
146*/
148 public:
149 Recovery_State() = default;
150
151 void reset() {
152 m_in_progress = false;
153 m_ineligible_warning = false;
154 m_offline_warning = false;
155 m_cycle_warning = false;
156 }
157
158 void hard_reset() {
159 reset();
160 m_count = 0;
161 m_expiration = 0;
162 }
163
164 [[nodiscard]] bool enabled() const { return m_enabled; }
166
167 [[nodiscard]] int level_pct() const { return m_level_pct; }
169
170 [[nodiscard]] int time_1() const { return m_time_1; }
172
173 [[nodiscard]] int time_2() const { return m_time_2; }
175
176 [[nodiscard]] int max_cycles() const { return m_max_cycles; }
178
179 [[nodiscard]] int increment() const { return m_increment; }
181
182 [[nodiscard]] uint64_t window() const { return m_window; }
183 void set_window(uint64_t value) { m_window = value; }
184
185 [[nodiscard]] uint64_t level_mb() const { return m_level_mb; }
186 void set_level_mb(uint64_t value) { m_level_mb = value; }
187
188 int count() const { return m_count; }
189 int &count() { return m_count; } // support ++/--
190 void set_count(int value) { m_count = value; }
191
192 [[nodiscard]] bool in_progress() const { return m_in_progress; }
194
195 [[nodiscard]] bool ineligible_warning() const { return m_ineligible_warning; }
197
198 [[nodiscard]] bool offline_warning() const { return m_offline_warning; }
200
201 [[nodiscard]] bool cycle_warning() const { return m_cycle_warning; }
203
204 [[nodiscard]] time_t expiration() const { return m_expiration; }
206
207 // Public for use as status variable 'disk_recovery_count'
208 int m_count{0}; // number of times recovery timer 1 was started
209
210 private:
211 // System variables
212 bool m_enabled{false}; // system variable 'disk_recovery_enable'
213 int m_level_pct{0}; // system variable 'disk_level_pct', percent above reserve level to set OFFLINE_MODE = OFF
214 int m_time_1{0}; // system variable 'disk_recovery_time_1', seconds before setting OFFLINE_MODE = OFF
215 int m_time_2{0}; // system variable 'disk_recovery_time_2', seconds before setting SUPER_READ_ONLY = OFF
216 int m_max_cycles{0}; // system variable 'disk_recovery_max_cycles', maximum allowed recovery cycles
217 int m_increment{0}; // system variable 'disk_recovery_increment', seconds to increase recovery timer each cycle
218 uint64_t m_window{0}; // system variable 'disk_recovery_window', lifetime of the recovery cycle count
219 // Recovery state
220 uint64_t m_level_mb{0}; // min MiB above reserve level to restore normal operating mode
221 bool m_in_progress{false}; // true if either recovery timer is running
222 bool m_ineligible_warning{false}; // true if server ineligible for recovery warning issued
223 bool m_offline_warning{false}; // true if OFFLINE_MODE warning issued
224 bool m_cycle_warning{false}; // true if recovery cycles exhausted warning issued
225 time_t m_expiration{0}; // the end of the recovery cycle window
226};
227
228/**
229 Disk Collector
230
231 The Disk Collector monitors space on the filesystem path specified by
232 `health_monitor.disk_monitored`. It collects filesystem usage, detects
233 filesystem and capacity changes, publishes samples and supplies disk metrics
234 to the Disk Forecaster.
235
236 The collector classifies available space as normal, warning, low or critical.
237 When fencing is enabled, low and critical states can cause the collector to
238 set OFFLINE_MODE and SUPER_READ_ONLY. The collector records which modes it
239 set so that when disk space recovers, the Health Monitor clears only changes
240 that it made.
241
242 If the monitored path or filesystem is unavailable, then the Disk Collector
243 suspends sample collection and retries on subsequent collection cycles.
244*/
245class Disk_Collector : public Collector {
246 public:
248 void initialize();
249
250 private:
251 void initialize_timers();
252 void advance_timers();
253
254 protected:
255 // Sample collection
256 void pre_process() override;
257 void process() override;
258 void post_process() override;
259
260 public:
261 // Settings
262 void set_buffer_size() final;
263 bool settings_changed() override;
264 void set_params() final;
265 [[nodiscard]] bool running() const override;
266
267 // Storage info
268 std::shared_ptr<Stat_Buffer<Disk_Info>> buffer() { return m_buffer; }
269 int get_disk_info(const std::string &target_path, Disk_Info &disk_info,
270 Filesystem_sample_state &sample_state,
271 Filesystem_change &change);
273 void update_disk_info();
274 void update_per_sample_totals(const Disk_Info &disk_info);
275 void set_storage_profile(const Disk_Info &disk_info);
276
277 // Fallback
281 void stop_fallback_timer();
283
284 bool fallback_eligible(std::string &reason);
285 bool fallback_eligible(bool print_reason = false);
287 void set_fallback_mode(bool force);
288 void clear_fallback_mode();
293
294 bool set_offline_mode(int max_retries, bool &already_set);
295 bool clear_offline_mode();
296 bool set_super_read_only(int max_retries, bool &already_set);
297 bool clear_super_read_only(int max_retries);
298
299 bool terminate_and_retry(const Processlist_Ids &plist_ids, int group_size,
300 bool query_only);
301 bool terminate_queries(const Processlist_Ids &plist_ids, int group_size) {
302 return terminate_and_retry(plist_ids, group_size, true);
303 }
304 bool terminate_connections(const Processlist_Ids &plist_ids, int group_size) {
305 return terminate_and_retry(plist_ids, group_size, false);
306 }
307
308 // Recovery
310 bool recovery_eligible(std::string &reason);
312 [[nodiscard]] bool above_recovery_level() const { return m_avail_mb >= m_recovery.level_mb(); }
313 [[nodiscard]] bool below_recovery_level() const { return m_avail_mb < m_recovery.level_mb(); }
316 bool max_recovery_cycles();
317 void set_recovery_window(bool print_status);
319
325
331
332 // Status variables
335 [[nodiscard]] bool offline_mode_disk_full() const { return m_status_offline_mode_disk_full; }
340 [[nodiscard]] std::string msg_setting_super_read_only_disk_full() const;
341 [[nodiscard]] std::string msg_setting_offline_mode_disk_full() const;
343 [[nodiscard]] int recovery_count() const { return m_recovery.m_count; }
344
345 // Collector state
346 static void set_state_params();
347 void set_state(ds::Storage_State &new_state);
356
365
366 // Time series collection
368 Disk_Forecaster *forecaster);
369
370 // Logging
371 std::string format_settings() override;
372 std::string format_status_info() override;
373 std::string tag_collector_state() override;
374 std::string tag_resource_state() override;
375 std::string tag_mode() override;
376 std::string tag_fallback();
377 std::string tag_recovery();
378 [[nodiscard]] std::string storage_status() const;
379 std::string timer_status(Mode_Timer &timer, const std::string &msg) const;
380 [[nodiscard]] std::string warning_status() const;
381
382 void log_info_message(const std::string &msg, bool levels);
383 void log_info_message(const std::string &msg);
384 void log_warning_status(const std::string &msg, bool levels);
385 void log_warning_status(const std::string &msg);
386 void log_warning_level([[maybe_unused]] int level);
390 void log_filesystem_recovery(const std::string &target_path);
391 void log_timer_status(Mode_Timer &timer);
392 void log_timer_status(Mode_Timer &timer, bool levels);
393 void log_timer_status(Mode_Timer &timer, const std::string &msg, bool levels);
394 void log_volume_change();
396 void log_resource_status() override;
397 void log_resource_levels() override;
398
399 // System variables
400 std::string m_configured_monitored; // configured monitored path
401 std::string m_monitored; // effective monitored path
402 uint64_t m_monitored_generation{0}; // version of the monitored path
403 int m_low_space_duration{0}; // seconds, fallback timer duration
404 uint64_t m_low_space_level{0}; // MiB below which starts fallback timer
405 int m_low_space_pct{0}; // percent of total space
406 uint64_t m_low_space_critical_level{0}; // MiB below which triggers fallback mode
407 int m_warn_level_1_pct{0}; // percent above reserve level, first warning level
408 int m_warn_level_2_pct{0}; // percent above reserve level, second warning level
409 int m_warn_level_3_pct{0}; // percent above reserve level, final warning level
410
411 std::atomic<bool> m_settings_changed{false};
412
413 // Storage thresholds in MiB
414 uint64_t m_total_space_mb{0}; // filesystem capacity
415 uint64_t m_operative_space_mb{0}; // total space - reserve
416 uint64_t m_warn_level_1_mb{0}; // MiB above reserve level
417 uint64_t m_warn_level_2_mb{0};
418 uint64_t m_warn_level_3_mb{0};
419 uint64_t m_reserve_mb{0}; // min of low space level and percent
421 bool m_refresh_storage_profile{false}; // true if mount point or settings change
422
423 // Current storage levels in MiB
424 uint64_t m_avail_mb{0}; // current available space
425 uint64_t m_last_avail_mb{0}; // previous available space
426
427 float m_used_pct{0}; // current used space, percent of total
428 int m_delta_pct{k_delta_pct}; // pct change in available space to trigger status message
429 uint64_t m_max_warn_level_mb{no_warn_level}; // top of the warning range, usually warn_level_1
430 uint64_t m_last_warn_level_mb{no_warn_level}; // previous warning level
431 Disk_Info m_info; // current storage stats, raw
432
433 // Fallback process
434 Fallback_State m_fallback; // state of the fallback process
435 Mode_Timer m_fallback_timer; // countdown timer to fallback mode
436
437 // Recovery process
438 Recovery_State m_recovery; // state of the recovery process
439 Mode_Timer m_recovery_timer_1; // countdown to setting OFFLINE_MODE = OFF
440 Mode_Timer m_recovery_timer_2; // countdown to setting SUPER_READ_ONLY = OFF
441
442 // Status variable 'offline_mode_disk_full'
443 // True if OFFLINE_MODE was set by the Health Monitor
445
446 // Status variable 'super_read_only_disk_full'
447 // True if SUPER_READ_ONLY was set by the Health Monitor
449
450 // A note on the different intervals:
451 // - The base interval is the time between resource checks
452 // - The sample interval is the time between stored samples, and is always
453 // a multiple of the base interval
454 // - The report interval is the time between resource status reports,
455 // and is a multiple of the sample interval
456 static constexpr int k_disk_base_interval{10};
457 // Reporting interval while the fallback timer is running (10 sec)
459 // Reporting interval while a recovery timer is running (10 sec)
461 // Number of attempts to set SUPER_READ_ONLY
462 static constexpr int k_fallback_retries{5};
463 // Percent change in disk space to trigger status message
464 static constexpr int k_delta_pct{10};
465
466 const std::string k_sample_timer{"Disk Sample Timer"};
468 const std::string k_fallback{"Fallback"};
469 const std::string k_fallback_timer{"Fallback Timer"};
470 const std::string k_fallback_error{"Fallback Error"};
471 const std::string k_recovery{"Recovery"};
472 const std::string k_recovery_error{"Recovery Error"};
473 const std::string k_recovery_timer_1{"Timer 1"};
474 const std::string k_recovery_timer_2{"Timer 2"};
477 const std::string k_normal_level{"Normal Level"};
478 const std::string k_low_level{"Low Level"};
479 const std::string k_warning_level{"Warning Level"};
480 const std::string k_critical_level{"Critical Level"};
481 const std::string k_running{"Running"};
482 const std::string k_expired{"Expired"};
483 const std::string k_canceled{"Canceled"};
484
485 // Filesystem state
488 bool m_new_volume{false}; // true if the monitored disk changes
489 bool m_new_size{false}; // true if the size of the current monitored disk changes
490 bool m_disk_error{false};
492 std::optional<std::string> m_unavailable_path;
494
495 private:
496 std::shared_ptr<Stat_Buffer<Disk_Info>> m_buffer;
499
506 &m_memory_key, "disk_collector", PSI_FLAG_ONLY_GLOBAL_STAT,
507 PSI_VOLATILITY_PROVISIONING, "Health Monitor disk metric buffer"};
508
510};
511
512// clang-format on
513
514} // namespace hm
Definition: health_monitor_collector.h:41
static constexpr uint64_t no_warn_level
Definition: health_monitor_collector.h:121
const std::string k_offline_mode
Definition: health_monitor_collector.h:125
const std::string k_super_read_only
Definition: health_monitor_collector.h:126
Disk Collector.
Definition: health_monitor_disk.h:245
Recovery_State m_recovery
Definition: health_monitor_disk.h:438
const std::string k_fallback
Definition: health_monitor_disk.h:468
void set_fallback_mode(bool force)
Set the server fallback mode, OFFLINE_MODE and SUPER_READ_ONLY.
Definition: health_monitor_disk.cc:622
const std::string k_recovery_timer_1
Definition: health_monitor_disk.h:473
std::string m_configured_monitored
Definition: health_monitor_disk.h:400
int m_delta_pct
Definition: health_monitor_disk.h:428
float m_used_pct
Definition: health_monitor_disk.h:427
void set_start_state()
Definition: health_monitor_disk.h:348
int m_low_space_pct
Definition: health_monitor_disk.h:405
static constexpr int k_fallback_report_interval
Definition: health_monitor_disk.h:458
uint64_t m_monitored_generation
Definition: health_monitor_disk.h:402
uint64_t m_reserve_mb
Definition: health_monitor_disk.h:419
bool set_offline_mode(int max_retries, bool &already_set)
Attempt to set OFFLINE_MODE.
Definition: health_monitor_disk.cc:868
int m_warn_level_2_pct
Definition: health_monitor_disk.h:408
Mode_Timer m_fallback_timer
Definition: health_monitor_disk.h:435
void process() override
Query and evaluate filesystem usage at the base interval.
Definition: health_monitor_disk.cc:124
void set_critical_state()
Definition: health_monitor_disk.h:353
void check_recovery_window()
Check the recovery window.
Definition: health_monitor_disk.cc:1311
int recovery_count() const
Definition: health_monitor_disk.h:343
void cancel_fallback_timer()
Cancel the fallback timer:
Definition: health_monitor_disk.cc:543
const std::string k_recovery_error
Definition: health_monitor_disk.h:472
uint64_t m_critical_level_mb
Definition: health_monitor_disk.h:420
bool * offline_mode_set_ptr()
Definition: health_monitor_disk.h:334
Mode_Timer m_recovery_timer_2
Definition: health_monitor_disk.h:440
PSI_rwlock_key m_rwlock_key
Definition: health_monitor_disk.h:500
void set_buffer_size() final
Resize the stat buffer if necessary.
Definition: health_monitor_disk.cc:238
bool m_new_size
Definition: health_monitor_disk.h:489
ds::Normal_State m_normal_state
Definition: health_monitor_disk.h:360
void clear_fallback_mode()
Clear OFFLINE_MODE and SUPER_READ_ONLY, reset all fallback state variables.
Definition: health_monitor_disk.cc:733
void update_offline_mode_disk_full()
Update the 'offline_mode_disk_full' status variable.
Definition: health_monitor_disk.cc:1394
bool m_new_volume
Definition: health_monitor_disk.h:488
std::string tag_recovery()
Recovery mode string: "Recovery".
Definition: health_monitor_disk.cc:1551
bool offline_mode_disk_full() const
Definition: health_monitor_disk.h:335
void start_recovery_timer_2()
Start the recovery_2 timer:
Definition: health_monitor_disk.cc:1371
void set_disk_metric_buffer(Disk_Metric_Buffer buffer, Disk_Forecaster *forecaster)
Set the time series buffer.
Definition: health_monitor_disk.cc:1841
void cancel_fallback_process()
Cancel the ongoing fallback process.
Definition: health_monitor_disk.cc:854
PSI_rwlock_info m_rwlock_info
Definition: health_monitor_disk.h:501
bool terminate_connections(const Processlist_Ids &plist_ids, int group_size)
Definition: health_monitor_disk.h:304
bool above_recovery_level() const
Definition: health_monitor_disk.h:312
std::string tag_resource_state() override
Resource state tag: Normal Level, Warning Level, etc.
Definition: health_monitor_disk.cc:1526
Filesystem_sample_state m_filesystem_sample_state
Definition: health_monitor_disk.h:486
uint64_t m_warn_level_2_mb
Definition: health_monitor_disk.h:417
void pre_process() override
Put the collector into the START state.
Definition: health_monitor_disk.cc:113
void log_timer_status(Mode_Timer &timer)
Timer status, no levels.
Definition: health_monitor_disk.cc:1705
bool settings_changed() override
Indicate if the Disk Collector settings have changed.
Definition: health_monitor_disk.cc:252
bool m_status_super_read_only_disk_full
Definition: health_monitor_disk.h:448
ds::Warning_State m_warning_state
Definition: health_monitor_disk.h:361
std::atomic< bool > m_settings_changed
Definition: health_monitor_disk.h:411
void check_recovery_status()
Check the recovery status after the server has been fenced.
Definition: health_monitor_disk.cc:1067
void set_low_limit_state()
Definition: health_monitor_disk.h:352
bool below_recovery_level() const
Definition: health_monitor_disk.h:313
void log_info_message(const std::string &msg, bool levels)
Log informational message with storage state, storage levels and message.
Definition: health_monitor_disk.cc:1623
void reset_fallback_and_recovery()
Reset fallback and recovery modes, cancel all timers.
Definition: health_monitor_disk.cc:836
void set_recovery_timeout_2()
Set the timeout for recovery timer 2.
Definition: health_monitor_disk.cc:1360
void cancel_recovery_timer_2()
Cancel the recovery_2 timer:
Definition: health_monitor_disk.cc:1386
void update_disk_info()
Update disk info for display only.
Definition: health_monitor_disk.cc:422
std::string timer_status(Mode_Timer &timer, const std::string &msg) const
Timer status with optional message: Started, Running, Expired, ...
Definition: health_monitor_disk.cc:1584
const std::string k_recovery
Definition: health_monitor_disk.h:471
ds::Low_Limit_State m_low_limit_state
Definition: health_monitor_disk.h:362
Mode_Timer m_recovery_timer_1
Definition: health_monitor_disk.h:439
bool fallback_eligible(std::string &reason)
Fallback eligible: Server is eligible to be placed in fallback mode if:
Definition: health_monitor_disk.cc:557
void initialize()
Initialize the Disk Collector.
Definition: health_monitor_disk.cc:60
bool set_super_read_only(int max_retries, bool &already_set)
Set SUPER_READ_ONLY.
Definition: health_monitor_disk.cc:924
std::string tag_collector_state() override
Collector state tag: Start, Stop, etc.
Definition: health_monitor_disk.cc:1506
bool m_status_offline_mode_disk_full
Definition: health_monitor_disk.h:444
void update_per_sample_totals(const Disk_Info &disk_info)
Update totals that change for each sample, convert to MiB.
Definition: health_monitor_disk.cc:392
Mode_Timer & fallback_timer()
Definition: health_monitor_disk.h:279
std::string format_settings() override
Disk Collector settings formatted string.
Definition: health_monitor_disk.cc:1444
void initialize_timers()
Initialize the fallback and recovery timers.
Definition: health_monitor_disk.cc:74
bool terminate_queries(const Processlist_Ids &plist_ids, int group_size)
Definition: health_monitor_disk.h:301
void log_volume_change()
The monitored disk has changed.
Definition: health_monitor_disk.cc:1732
uint64_t m_operative_space_mb
Definition: health_monitor_disk.h:415
bool terminate_and_retry(const Processlist_Ids &plist_ids, int group_size, bool query_only)
Terminate queries or connections until SUPER_READ_ONLY can be set.
Definition: health_monitor_disk.cc:988
void process_expired_fallback_timer()
Process expired fallback timer.
Definition: health_monitor_disk.cc:822
uint64_t m_max_warn_level_mb
Definition: health_monitor_disk.h:429
std::string tag_mode() override
Mode string: Fallback, Timer, etc.
Definition: health_monitor_disk.cc:1531
void check_storage_levels()
Check the available space against the storage thresholds:
Definition: health_monitor_disk.cc:1820
bool m_disk_error
Definition: health_monitor_disk.h:490
void set_recovery_timeout_1()
Set the timeout for recovery timer 1.
Definition: health_monitor_disk.cc:1325
std::string m_monitored
Definition: health_monitor_disk.h:401
Recovery_State & recovery()
Definition: health_monitor_disk.h:309
const std::string k_normal_level
Definition: health_monitor_disk.h:477
void stop_recovery_timer_1()
Stop the recovery_1 timer:
Definition: health_monitor_disk.cc:1343
void log_volume_size_change()
Size of the monitored disk has changed.
Definition: health_monitor_disk.cc:1741
std::shared_ptr< Stat_Buffer< Disk_Info > > buffer()
Definition: health_monitor_disk.h:268
void set_error_state()
Definition: health_monitor_disk.h:354
const std::string k_canceled
Definition: health_monitor_disk.h:483
ds::Start_State m_start_state
Definition: health_monitor_disk.h:358
bool forced_fallback_eligible()
Return true if forced fallback is allowed.
Definition: health_monitor_disk.cc:613
void log_filesystem_recovery(const std::string &target_path)
Log filesystem recovery after an unavailable transition.
Definition: health_monitor_disk.cc:1697
bool running() const override
Return health_monitor.disk_running.
Definition: health_monitor_disk.cc:338
void log_warning_error_condition()
Error condition warning.
Definition: health_monitor_disk.cc:1683
void set_normal_state()
Definition: health_monitor_disk.h:350
void cancel_recovery_timer_1()
Cancel the recovery_1 timer:
Definition: health_monitor_disk.cc:1351
void advance_timers()
Advance the timers driven by the collection interval.
Definition: health_monitor_disk.cc:95
int get_disk_info(const std::string &target_path, Disk_Info &disk_info, Filesystem_sample_state &sample_state, Filesystem_change &change)
Get available free space for a monitored filesystem.
Definition: health_monitor_disk.cc:348
std::shared_ptr< Stat_Buffer< Disk_Info > > m_buffer
Definition: health_monitor_disk.h:496
static constexpr int k_delta_pct
Definition: health_monitor_disk.h:464
void set_storage_profile(const Disk_Info &disk_info)
Set the storage threshold parameters for the monitored filesystem.
Definition: health_monitor_disk.cc:440
PSI_memory_info m_memory_info
Definition: health_monitor_disk.h:505
const std::string k_recovery_timer_2
Definition: health_monitor_disk.h:474
Disk_Metric_Buffer m_disk_metric_buffer
Definition: health_monitor_disk.h:497
void stop_recovery_timer_2()
Stop the recovery_2 timer:
Definition: health_monitor_disk.cc:1378
void set_state(ds::Storage_State &new_state)
Set the next state based on the available space.
Definition: health_monitor_disk.cc:1803
std::string storage_status() const
Build storage state string.
Definition: health_monitor_disk.cc:1556
bool clear_offline_mode()
Clear OFFLINE_MODE.
Definition: health_monitor_disk.cc:900
void start_recovery_timer_1()
Start the recovery_1 timer:
Definition: health_monitor_disk.cc:1336
bool recovery_eligible(std::string &reason)
Recovery eligible.
Definition: health_monitor_disk.cc:1029
Input_failure
Definition: health_monitor_disk.h:491
const std::string k_recovery_2_mode
Definition: health_monitor_disk.h:476
void update_super_read_only_disk_full()
Update the 'super_read_only_disk_full' status variable.
Definition: health_monitor_disk.cc:1405
std::optional< std::string > m_unavailable_path
Definition: health_monitor_disk.h:492
int * recovery_count_ptr()
Definition: health_monitor_disk.h:342
void cancel_recovery_process()
Cancel the recovery process:
Definition: health_monitor_disk.cc:1264
static constexpr int k_disk_base_interval
Definition: health_monitor_disk.h:456
int m_low_space_duration
Definition: health_monitor_disk.h:403
const std::string k_low_level
Definition: health_monitor_disk.h:478
void log_warning_status(const std::string &msg, bool levels)
Log warning with storage state, fallback state, storage levels and message.
Definition: health_monitor_disk.cc:1639
void log_warning_level()
Definition: health_monitor_disk.h:387
void start_fallback_timer()
Start the fallback timer.
Definition: health_monitor_disk.cc:529
void set_warning_state()
Definition: health_monitor_disk.h:351
Server m_server
Definition: health_monitor_disk.h:509
void post_process() override
Put the collector into the STOP state, which will cancel active timers, issue status messages,...
Definition: health_monitor_disk.cc:227
Mode_Timer & recovery_timer_1()
Definition: health_monitor_disk.h:320
static constexpr int k_recovery_report_interval
Definition: health_monitor_disk.h:460
const std::string k_expired
Definition: health_monitor_disk.h:482
bool max_recovery_cycles()
Check if the max recovery cycle count has been reached.
Definition: health_monitor_disk.cc:1283
void complete_recovery_process()
Complete the recovery process:
Definition: health_monitor_disk.cc:1237
bool clear_super_read_only(int max_retries)
Clear READ_ONLY and SUPER_READ_ONLY.
Definition: health_monitor_disk.cc:958
Disk_Info m_info
Definition: health_monitor_disk.h:431
PSI_memory_key m_memory_key
Definition: health_monitor_disk.h:504
void stop_fallback_timer()
Stop the fallback timer.
Definition: health_monitor_disk.cc:534
const std::string k_running
Definition: health_monitor_disk.h:481
const std::string k_warning_level
Definition: health_monitor_disk.h:479
uint64_t m_warn_level_3_mb
Definition: health_monitor_disk.h:418
uint64_t m_avail_mb
Definition: health_monitor_disk.h:424
Filesystem_change m_filesystem_change
Definition: health_monitor_disk.h:487
uint64_t m_low_space_level
Definition: health_monitor_disk.h:404
std::string tag_fallback()
Fallback mode string: "Fallback".
Definition: health_monitor_disk.cc:1546
std::string format_status_info() override
Storage info formatted string.
Definition: health_monitor_disk.cc:1483
const std::string k_fallback_error
Definition: health_monitor_disk.h:470
ds::Error_State m_error_state
Definition: health_monitor_disk.h:364
void set_stop_state()
Definition: health_monitor_disk.h:349
Mode_Timer & recovery_timer_2()
Definition: health_monitor_disk.h:326
Fallback_State & fallback()
Definition: health_monitor_disk.h:278
Input_failure m_input_failure
Definition: health_monitor_disk.h:493
Disk_Collector()
Disk Collector constructor.
Definition: health_monitor_disk.cc:45
uint64_t m_last_warn_level_mb
Definition: health_monitor_disk.h:430
void set_params() final
Set collection parameters from the system variables.
Definition: health_monitor_disk.cc:283
Fallback_State m_fallback
Definition: health_monitor_disk.h:434
void log_resource_levels() override
Log the current storage levels, no message.
Definition: health_monitor_disk.cc:1750
const std::string k_critical_level
Definition: health_monitor_disk.h:480
Disk_Forecaster * m_disk_forecaster
Definition: health_monitor_disk.h:498
void set_recovery_window(bool print_status)
Set the end of the recovery window.
Definition: health_monitor_disk.cc:1295
bool resolve_monitored_path()
Resolve the automatic monitored path before filesystem collection.
Definition: health_monitor_disk.cc:179
uint64_t m_low_space_critical_level
Definition: health_monitor_disk.h:406
std::string msg_setting_offline_mode_disk_full() const
Definition: health_monitor_disk.cc:1434
int m_warn_level_3_pct
Definition: health_monitor_disk.h:409
uint64_t m_total_space_mb
Definition: health_monitor_disk.h:414
std::string warning_status() const
Warning level string: Warning Level 1, Warning Level 2, ...
Definition: health_monitor_disk.cc:1605
const std::string k_recovery_1_mode
Definition: health_monitor_disk.h:475
bool m_refresh_storage_profile
Definition: health_monitor_disk.h:421
ds::Storage_State * m_current_state
Definition: health_monitor_disk.h:357
void update_fallback_status_vars()
Update fallback status variables, log changes.
Definition: health_monitor_disk.cc:1417
int m_warn_level_1_pct
Definition: health_monitor_disk.h:407
void log_resource_status() override
Collector or storage status with levels, depending on state.
Definition: health_monitor_disk.cc:1755
const std::string k_sample_timer
Definition: health_monitor_disk.h:466
ds::Critical_State m_critical_state
Definition: health_monitor_disk.h:363
bool check_fenced_server_state()
Check if the state of a fenced server changed:
Definition: health_monitor_disk.cc:766
const std::string k_fallback_timer
Definition: health_monitor_disk.h:469
std::string msg_setting_super_read_only_disk_full() const
Log messages for updates to status variables 'super_read_only_disk_full' and 'offline_mode_disk_full'...
Definition: health_monitor_disk.cc:1427
bool * super_read_only_set_ptr()
Definition: health_monitor_disk.h:333
bool super_read_only_disk_full() const
Definition: health_monitor_disk.h:336
static void set_state_params()
Set threshold params for all storage states.
Definition: health_monitor_disk.cc:1798
uint64_t m_warn_level_1_mb
Definition: health_monitor_disk.h:416
uint64_t m_last_avail_mb
Definition: health_monitor_disk.h:425
void log_warning_low_limit()
Low space warning with timer state.
Definition: health_monitor_disk.cc:1666
static constexpr int k_fallback_retries
Definition: health_monitor_disk.h:462
const std::string k_fallback_mode
Definition: health_monitor_disk.h:467
ds::Stop_State m_stop_state
Definition: health_monitor_disk.h:359
Definition: health_monitor_disk_forecaster.h:40
Fallback State.
Definition: health_monitor_disk.h:52
bool m_enabled
Definition: health_monitor_disk.h:124
void set_enabled(bool value)
Definition: health_monitor_disk.h:72
bool force_enabled() const
Definition: health_monitor_disk.h:74
Fallback_State()=default
std::string & last_reason()
Definition: health_monitor_disk.h:116
bool super_read_only_was_set_by_hm() const
Definition: health_monitor_disk.h:89
bool force_attempted() const
Definition: health_monitor_disk.h:109
const ds::Storage_State * last_state() const
Definition: health_monitor_disk.h:120
void set_last_reason(const std::string &value)
Definition: health_monitor_disk.h:118
void set_super_read_only_force_failed(bool value)
Definition: health_monitor_disk.h:105
void set_count(int value)
Definition: health_monitor_disk.h:114
bool fenced() const
Definition: health_monitor_disk.h:79
void set_super_read_only_retry_failed(bool value)
Definition: health_monitor_disk.h:98
int m_count
Definition: health_monitor_disk.h:133
bool offline_mode_was_set_by_hm() const
Definition: health_monitor_disk.h:83
void reset()
Definition: health_monitor_disk.h:56
bool enabled() const
Definition: health_monitor_disk.h:71
void set_force_enabled(bool value)
Definition: health_monitor_disk.h:75
bool m_super_read_only_was_set_by_hm
Definition: health_monitor_disk.h:127
bool super_read_only_force_failed() const
Definition: health_monitor_disk.h:102
std::string m_last_reason
Definition: health_monitor_disk.h:131
const std::string & last_reason() const
Definition: health_monitor_disk.h:117
bool m_offline_mode_was_set_by_hm
Definition: health_monitor_disk.h:126
ds::Storage_State * m_last_state
Definition: health_monitor_disk.h:132
bool m_force_enabled
Definition: health_monitor_disk.h:125
bool m_force_attempted
Definition: health_monitor_disk.h:130
int count() const
Definition: health_monitor_disk.h:112
bool super_read_only_retry_failed() const
Definition: health_monitor_disk.h:95
int & count()
Definition: health_monitor_disk.h:113
void set_last_state(ds::Storage_State *state)
Definition: health_monitor_disk.h:121
void set_force_attempted(bool value)
Definition: health_monitor_disk.h:110
void hard_reset()
Definition: health_monitor_disk.h:66
bool set_super_read_only_was_set_by_hm(bool value)
Definition: health_monitor_disk.h:90
bool m_super_read_only_force_failed
Definition: health_monitor_disk.h:129
bool set_offline_mode_was_set_by_hm(bool value)
Definition: health_monitor_disk.h:84
bool m_super_read_only_retry_failed
Definition: health_monitor_disk.h:128
Server mode timer used for fallback mode, recovery mode, etc.
Definition: health_monitor_timer.h:47
Recovery State.
Definition: health_monitor_disk.h:147
void set_window(uint64_t value)
Definition: health_monitor_disk.h:183
uint64_t m_level_mb
Definition: health_monitor_disk.h:220
bool ineligible_warning() const
Definition: health_monitor_disk.h:195
void reset()
Definition: health_monitor_disk.h:151
uint64_t m_window
Definition: health_monitor_disk.h:218
time_t m_expiration
Definition: health_monitor_disk.h:225
int & count()
Definition: health_monitor_disk.h:189
void set_in_progress(bool value)
Definition: health_monitor_disk.h:193
time_t expiration() const
Definition: health_monitor_disk.h:204
uint64_t level_mb() const
Definition: health_monitor_disk.h:185
uint64_t window() const
Definition: health_monitor_disk.h:182
int increment() const
Definition: health_monitor_disk.h:179
void set_time_2(int value)
Definition: health_monitor_disk.h:174
int max_cycles() const
Definition: health_monitor_disk.h:176
void set_expiration(time_t value)
Definition: health_monitor_disk.h:205
bool m_enabled
Definition: health_monitor_disk.h:212
void set_max_cycles(int value)
Definition: health_monitor_disk.h:177
void set_level_pct(int value)
Definition: health_monitor_disk.h:168
int count() const
Definition: health_monitor_disk.h:188
bool enabled() const
Definition: health_monitor_disk.h:164
bool m_in_progress
Definition: health_monitor_disk.h:221
bool cycle_warning() const
Definition: health_monitor_disk.h:201
int m_level_pct
Definition: health_monitor_disk.h:213
int m_max_cycles
Definition: health_monitor_disk.h:216
void set_ineligible_warning(bool value)
Definition: health_monitor_disk.h:196
int m_time_2
Definition: health_monitor_disk.h:215
int m_time_1
Definition: health_monitor_disk.h:214
void set_enabled(bool value)
Definition: health_monitor_disk.h:165
bool m_ineligible_warning
Definition: health_monitor_disk.h:222
int time_1() const
Definition: health_monitor_disk.h:170
bool m_cycle_warning
Definition: health_monitor_disk.h:224
void set_level_mb(uint64_t value)
Definition: health_monitor_disk.h:186
int time_2() const
Definition: health_monitor_disk.h:173
void set_cycle_warning(bool value)
Definition: health_monitor_disk.h:202
bool in_progress() const
Definition: health_monitor_disk.h:192
void hard_reset()
Definition: health_monitor_disk.h:158
int m_increment
Definition: health_monitor_disk.h:217
void set_count(int value)
Definition: health_monitor_disk.h:190
int m_count
Definition: health_monitor_disk.h:208
void set_offline_warning(bool value)
Definition: health_monitor_disk.h:199
int level_pct() const
Definition: health_monitor_disk.h:167
void set_time_1(int value)
Definition: health_monitor_disk.h:171
bool m_offline_warning
Definition: health_monitor_disk.h:223
bool offline_warning() const
Definition: health_monitor_disk.h:198
void set_increment(int value)
Definition: health_monitor_disk.h:180
Recovery_State()=default
Server utility class.
Definition: health_monitor_server.h:73
Critical State.
Definition: health_monitor_disk_state.h:163
Error State.
Definition: health_monitor_disk_state.h:177
Low Limit State.
Definition: health_monitor_disk_state.h:149
Normal State.
Definition: health_monitor_disk_state.h:122
Start State.
Definition: health_monitor_disk_state.h:97
Stop State.
Definition: health_monitor_disk_state.h:111
Definition: health_monitor_disk_state.h:34
Warning State.
Definition: health_monitor_disk_state.h:134
#define PSI_DOCUMENT_ME
Definition: component_common.h:29
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:35
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:44
#define PSI_VOLATILITY_PROVISIONING
Definition: psi_bits.h:155
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_bits.h:112
Definition: component_command.h:29
Filesystem_change
Definition: health_monitor_filesystem_sample.h:36
std::shared_ptr< Metric_Buffer< Disk_Metric > > Disk_Metric_Buffer
Definition: health_monitor_disk_bits.h:72
std::vector< std::string > Processlist_Ids
Definition: health_monitor_server.h:36
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Memory instrument information.
Definition: psi_memory_bits.h:58
Rwlock information.
Definition: psi_rwlock_bits.h:162
Disk Info Record structure for health_block_device.
Definition: health_monitor_disk_bits.h:36
Definition: health_monitor_filesystem_sample.h:43