Repository navigation
Fix overload warnings reading stale async-metrics values (one-cycle lag) - #108035
Conversation
In AsynchronousMetrics::update, after values.swap(new_values) the warning helpers were still passed new_values, which then holds the previous cycle's data. This lagged system.warnings by one cycle and emitted nothing on the first cycle. Pass the freshly computed `values` instead. Closes: #101759 Related: #102779 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [31fcf9c] Summary: ✅
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
|
Status: ready to merge pending maintainer override.
Remaining non-green checks are not caused by this change:
The fix is unchanged ( |
Adds a deterministic regression test for the one-cycle lag fixed in this change. With `asynchronous_metrics_update_period_s` set very large, only the synchronous update performed at server startup runs before the test queries `system.warnings`. The config also forces the memory-overload warning to fire unconditionally on that first cycle (`memory_overload_warn_ratio` 0, `memory_overload_duration_seconds` 0). With the bug, the first cycle reads the empty post-swap `new_values` and emits no warning; with the fix it reads the freshly computed `values` and the warning `High ClickHouse memory usage: ...` is present immediately after start. Verified locally: on the fixed binary the warning is present after startup (count 1); on the unfixed binary it is absent after startup (count 0) and only appears after one further `SYSTEM RELOAD ASYNCHRONOUS METRICS`, confirming the one-cycle lag. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Added a deterministic regression test and refreshed the branch on current New test: Verified locally on both binaries:
So the test fails on Build sanity: |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code |
…-stale-warnings Fix overload warnings reading stale async-metrics values (one-cycle lag)
In
AsynchronousMetrics::update, aftervalues.swap(new_values)the warning helpers were still passednew_values, which after the swap holds the previous cycle's data. SoprocessWarningForMutationStats,processWarningForMemoryOverloadandprocessWarningForCPUOverloadread stale metrics:system.warningslagged one async-metrics cycle, and on the very first cyclenew_valuesis empty, so no warning was emitted even when a threshold was exceeded. This passesvalues(the freshly computed metrics) instead.Testing: added a deterministic regression test (
tests/integration/test_async_metrics_overload_warning). It sets a very largeasynchronous_metrics_update_period_sso that only the synchronous update performed once at server startup has run by the time the test queriessystem.warnings, and forces the memory-overload warning to fire unconditionally on that first cycle (memory_overload_warn_ratio0,memory_overload_duration_seconds0). Without the fix, the first cycle reads the empty post-swapnew_valuesand emits no warning (the test fails); with the fix it reads the freshly computedvaluesand the warningHigh ClickHouse memory usage: ...is present immediately after start (the test passes). Verified locally on both the fixed and the unfixed binary: with the unfixed binary the warning is absent after startup and only appears after one furtherSYSTEM RELOAD ASYNCHRONOUS METRICS, confirming the one-cycle lag.This revives the change from the closed PR #102779 (closed for process reasons) and rebases it onto current
master.Closes: #101759
Related: #102779
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed memory/CPU/mutation overload warnings in
system.warningslagging one asynchronous-metrics cycle behind (and being absent on the first cycle).Documentation entry for user-facing changes
Version info
26.7.1.328(included in26.7and later)