Skip to content

AsynchronousMetrics: pass current values to processWarning* after swap - #102779

Closed
SAY-5 wants to merge 1 commit into
ClickHouse:masterfrom
SAY-5:fix-async-metrics-warning-stale
Closed

SAY-5 wants to merge 1 commit into
ClickHouse:masterfrom
SAY-5:fix-async-metrics-warning-stale

Conversation

@SAY-5

@SAY-5 SAY-5 commented Apr 15, 2026

Copy link
Copy Markdown

Closes #101759.

AsynchronousMetrics::update() swaps the freshly computed values into values and then feeds new_values into the warning helpers:

values.swap(new_values);
processWarningForMutationStats(new_values);
processWarningForMemoryOverload(new_values);
processWarningForCPUOverload(new_values);

After the swap, values holds the fresh metrics and new_values holds the previous cycle's snapshot, so system.warnings lags reality by one async metrics cycle for mutation backlog, memory overload, and CPU overload — and on the very first cycle new_values is empty/default after the swap, so no warnings are emitted at all even when thresholds are clearly exceeded.

Read from values instead so the warning helpers see the same data the rest of the system sees. Verified against current master.

AsynchronousMetrics::update() called values.swap(new_values) and then
passed new_values to processWarningForMutationStats /
processWarningForMemoryOverload / processWarningForCPUOverload. After
the swap, values holds the freshly computed metrics and new_values
holds the previous cycle's data, so the warning helpers always read
the previous cycle's snapshot. On the very first async metrics cycle
new_values is empty/default after the swap, so no warnings are emitted
even when the thresholds are clearly exceeded; afterwards the warning
state lags reality by one cycle.

Read from values instead so the warnings reflect the current cycle's
metrics.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


SAY-5 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request Jul 1, 2026
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: ClickHouse#101759
Related: ClickHouse#102779

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
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: ClickHouse#101759
Related: ClickHouse#102779

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

processWarning methods use stale metrics after values.swap(new_values)

3 participants