Repository navigation
Make test_server_overload deterministic under the metrics-reset window - #115905
alexey-milovidov merged 1 commit into
Conversation
test_server_overload::test_overload still failed intermittently after ClickHouse#113529, which removed the Bernoulli lottery but left a sampling lottery. checkCPUOverload calls getCPUOverload(os_cpu_busy_time_threshold) with reset defaulted false (ProfileEvents.cpp:1972). getCPUOverload returns 0 at :2039 while the busy time accrued since the last reset is below the threshold, and on 0 the caller's `cpu_load > DBL_EPSILON` test fails, so the ratio, the probability ramp and the draw are never evaluated. The only reset=true caller is AsynchronousMetrics.cpp:2734, so both consumers share one prev_* pair: every reset window opens at zero busy time and its first threshold/busy_rate is a window in which an overloaded server provably cannot throw. The probe loop samples that grid at about 0.99 s per iteration, because each node1.query() spawns a fresh clickhouse-client process against a one-core-pinned server, so the 0.3 s sleep is not the period. Against the reset cadence that is a near-resonance: the phase drifts only about 9 ms per iteration, so a run whose starting phase lands inside the blind window stays inside it for every probe that overlaps the 30 s load, and the loop falls through to the assertion. On the failing CI runner the per-probe busy time was around 8000 us against the 300000 us budget. Setting the fixture's threshold to 0 removes the blind window, so the verdict follows the measured wait/busy ratio rather than the probe's arrival time. 0 is the degenerate in-domain value rather than another calibrated constant: at :2039 the test becomes busy_delta <= 0 || wait_delta <= 0, exactly the liveness precondition the ratio needs to be defined. Anything larger has to encode a busy rate and a reset cadence that the setting cannot observe, which is why a smaller nonzero value was measured to change no outcome at all. This does not weaken the test. What excludes an unloaded server is min_os_cpu_wait_time_ratio_to_throw, not the busy-time budget: measured on an idle node at threshold 0, the ratios that now reach the ramp are 0.14 to 0.47, all giving probability 0 and no throw, while 5 of 9 idle windows are still refused on the wait_delta clause. Both "probability ... 1." assertions from ClickHouse#113529 are kept, so the saturated ramp remains the thing under test, and the test now throws on its first probe instead of iterating. Validated in both directions. With the fix, test_overload passes 10/10 on debug, 10/10 on asan+ubsan and 50/50. With the throttle mutated it still reddens: checkCPUOverload returning early fails 3/3, the probability ramp forced to 0 fails 3/3, and the threshold set unreachably high fails 3/3, each with the assertion CI reported. The pre-fix config plus a disabled throttle also fails 3/3, so the sensitivity was not created by this change. test_drop_connections passes 10/10 with its own config untouched. node2's early_drop.xml keeps the same budget: it shares the blind window but is green today, and its config also carries the drop-connection ratios. The product default os_cpu_busy_time_threshold = 1'000'000 is also unchanged; the shared prev_* pair gives any server a short blind window each period, which is a product question rather than one to settle from a test fix.
Internal second-model review (click to expand)Two independent reviews of this diff: a cold read of the resulting code, and a separate
Also verified: template headers byte-identical to current upstream, one changelog category, |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20260822-081400 |
|
Workflow [PR], commit [30927aa] Summary: ✅ AI ReviewSummaryThis PR makes Final Verdict✅ No blocking issues found. |
|
cc @alexkats, could you review this? The fixture's |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
f252e70
… test_server_overload
test_overload asserted the rendered value of the throttle's rejection
probability ("probability used to decide whether to discard the query 1."),
i.e. p == 1. Both setting pairs document p as a linear interpolation between
min and max ratio, and ProfileEvents::checkCPUOverload implements exactly
that: p = (clamp(cpu_load, min, max) - min) / (max - min), followed by one
Bernoulli draw. With the test's min=1, max=1.5, p reaches 1 only when the
runner's wait/busy ratio reaches 1.5. The CI runners that run this test
produce 1.287 - 1.393, so p is fractional and the second assertion fails
while the rejection itself is correct: the observed 1.2870989304812834 gives
0.5741978609625669, matching the failure log exactly. The assertion was a
statement about the runner, not about ClickHouse.
Drop the asserted value on both carriers and keep the message check. The
query-path assertion is rewritten value-free rather than deleted, because
SERVER_OVERLOADED is also raised by the workload scheduler (FifoQueue,
AllocationQueue), so asserting the error code alone would no longer pin the
rejection to the CPU throttle. On the connection path the identical assertion
is deleted outright, since the preceding line already asserts the same string
without its value.
max = 1.5 is kept on both paths: at the ratios CI produces it puts the
per-probe rejection probability at 0.57 - 0.79, so a rejection within the
test's 60 probes is effectively certain. The two comments stating the refuted
premise (that max is below the ratio the load produces, so the ramp
saturates) are rewritten to state the ramp semantics instead.
Verified by constructing the CI condition locally. This box reaches ratios of
3.5 - 7.1, above max, which is why the stock test passes here, so max was
raised above that range to put the ratio inside the band. On the unfixed tree
test_overload then fails 5/5 with the exact CI assertion and fractional
probabilities; with this change, on the same binary and configuration, it
passes 5/5, and 50/50 on the shipping config. Removing only the probability
clause from the server message reddens exactly the two rewritten assertions
while the error-code and log-line assertions still pass; zeroing the ramp,
disabling the check, and removing the synthetic load each still redden the
behavioural oracle.
Follow-up to ClickHouse#113529 and ClickHouse#115905.
Co-Authored-By: Claude Opus 5 <[email protected]>
Related: #113529
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
test_server_overload::test_overloadstill fails intermittently with #113529 merged(run).
That PR removed the Bernoulli lottery; a sampling one remained.
checkCPUOverloadreadsgetCPUOverload(os_cpu_busy_time_threshold)withreset=false(
ProfileEvents.cpp:1972), which returns 0 at:2039while busy time accrued since the last reset isbelow the threshold; on 0 the ratio, the ramp and the draw are never evaluated. The only resetting caller
is
AsynchronousMetrics.cpp:2734, so every window opens at zero busy time and its firstthreshold / busy_ratecannot throw - ~0.43 s on the failing runner. The probe loop samples that grid at~0.99 s (a fresh
clickhouse-clientper probe, not the 0.3 s sleep), drifting only ~9 ms per iteration,so a run starting inside that window stays there.
Setting the fixture's
os_cpu_busy_time_thresholdto0makes the measured ratio decide, not theprobe's arrival time.
0is not a tuned constant: it degenerates to the liveness precondition the rationeeds (no zero denominator, no ratio from an idle window). What excludes an unloaded server is
min_os_cpu_wait_time_ratio_to_throw, not this budget - on an idle node at threshold0the ratiosreaching the ramp are 0.137-0.470, all probability 0. Both
probability ... 1.assertions from #113529are kept, and the test now throws on probe 1.
Validated both directions: with the fix
test_overloadpasses 10/10 debug, 10/10 asan+ubsan and 50/50,test_drop_connections10/10; withcheckCPUOverloadreturning early, the ramp forced to 0, or thethreshold unreachably high it fails 3/3 each with CI's assertion.
Left alone: node2's
early_drop.xmlkeeps300000- it shares the blind window but is green, and itsconfig also carries the drop-connection ratios.
helpers/min_cpu_busy_time.xmlholds300000too, butnothing references it. The product default
1'000'000is unchanged - twogetCPUOverloadconsumerssharing one
prev_*pair gives any server a short blind window each period, a product question ratherthan a test fix.
Workflow [PR]
Sync PR [sync-upstream/pr/115905]
Version info
26.8.1.1931(included in26.8and later)