Skip to content

Make test_status_counts fail with the reload's own error when SYSTEM RELOAD DICTIONARY fails - #133141

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-test-status-counts-reraise-reload-error
Nov 20, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-test-status-counts-reraise-reload-error

Conversation

@groeneai

@groeneai groeneai commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #132816

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not required.

Description

Follow-up to #132816, as suggested in #132816 (comment).

metrics_during_load in test_dictionary_asynchronous_metrics/test.py::test_status_counts ran SYSTEM RELOAD DICTIONARY d_slow in a threading.Thread and only joined it. The thread's exception reached only threading.excepthook, so a failed reload was retried as a timing miss (ending in the misleading the metrics were never computed while d_slow was LOADING), and in the LOADED_AND_RELOADING check the test passed with a thread warning, because a failed reload of a loaded dictionary keeps it LOADED.

The reload now runs through ThreadPoolExecutor.submit, and future.result() re-raises its exception before a sample is retried or accepted. Retries, assertions and the d_fail part are unchanged. Test-only change.

Validation (local integration harness, debug build): with local-only mutations that make the reload fail, the old test fails with the timing message after 5 attempts, fails at a later unrelated assert, or passes with only a thread warning; the new one fails on the first attempt with the server's error (Code: 60, 36 or 395), in both checks and on both exits of the helper. Unmutated, 50/50 runs pass, each check on its first attempt.


Workflow [PR]
Sync PR [sync-upstream/pr/133141]

Version info

  • Merged into: 26.12.1.15-master (included in 26.12 and later)

`metrics_during_load` ran `SYSTEM RELOAD DICTIONARY d_slow` in a
`threading.Thread` and only joined it. A thread's exception reaches only
`threading.excepthook`, so a failed reload before the poll saw the
in-progress status was retried as a timing miss (ending in the misleading
"the metrics were never computed while d_slow was LOADING"), and in the
LOADED_AND_RELOADING check a failed reload kept the dictionary LOADED, so
its sample was accepted and the test passed with only a thread warning.

Run the reload through `ThreadPoolExecutor.submit` and call
`future.result()` on both exits of the helper, the early return and after
the sample, so a failed reload raises its own error before a sample is
retried or accepted. `result()` waits like `join()`, and the executor's
`shutdown(wait=True)` still waits for the reload when the main thread
raises. Retries, assertions and the `d_fail` part are unchanged.

Follow-up to ClickHouse#132816, as suggested in
ClickHouse#132816 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 If the sample query itself raises while the reload also fails, the reload's error is not reported (the old thread printed it as a warning) (test.py:164-175) AGREE, not changed The test still fails with the sample query's error; noted, not blocking.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-10:20261120-025800

@clickhouse-gh

clickhouse-gh Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [76b4203]

Summary: ✅


AI Review

Summary

Reviewed #133141 at 76b42032ae4b4f890db17dd63b1913af801f3832. The change makes metrics_during_load propagate dictionary reload exceptions through Future.result before accepting or retrying a metric sample, preserving worker cleanup and existing assertions. No actionable findings. All 14 focused deterministic checks of the actual helper passed; the full integration test was not rerun.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, with local-only mutations that make SYSTEM RELOAD DICTIONARY d_slow fail: a second-load failure lets the old test PASS with a thread warning; a fast failure makes it fail with the timing message after 5 retries. 3/3 each.
b Root cause explained? The reload's threading.Thread exception went only to threading.excepthook and join() never raises, so the helper retried or accepted a sample without knowing whether the reload failed.
c Fix matches root cause? Yes. ThreadPoolExecutor.submit + future.result() re-raise the reload's exception on both exits of the helper. No retry count, bound or timeout changed.
d Test intent preserved / new tests added? Yes. Assertions, timing-miss retries and the d_fail part unchanged; unmutated 50/50 pass, each check on its first attempt.
e Both directions demonstrated? Yes. Old test: PASS with a warning / timing message after 5 attempts / a later unrelated assert. New test: all four mutations FAIL on attempt 1 with the server's error (Code: 395, 60, 36, 395).
f Fix is general across code paths? Yes. Both exits of the helper, in both the LOADING and LOADED_AND_RELOADING checks. It is the only background query in the module.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). Ran under 5 random-settings draws.
h Backward compatible? (maintainer-approved exception only) N/A (test-only; no settings, formats or product code).
i Invariants and contracts preserved? Yes. The reload is always finished before the helper returns: result() waits, and shutdown(wait=True) covers a main-thread exception like the old finally: join().

Session id: cron:clickhouse-impl-slot-41:20261120-022300

@clickhouse-gh clickhouse-gh Bot added the can be tested Allows running workflows for external contributors label Nov 20, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-dictionary Dictionaries (in-memory key-value, periodically refreshed from sources). label Nov 20, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 20, 2026
Merged via the queue into ClickHouse:master with commit 7b2deb3 Nov 20, 2026
576 of 578 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-dictionary Dictionaries (in-memory key-value, periodically refreshed from sources). pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants