Skip to content

Fix flaky test 05457_dictionary_remote_clickhouse_invalidate_query - #129879

Merged
vdimir merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05457-dictionary-remote-invalidate-query
Nov 7, 2026
Merged

vdimir merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05457-dictionary-remote-invalidate-query

Conversation

@groeneai

@groeneai groeneai commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129336

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):

Fix flaky test 05457_dictionary_remote_clickhouse_invalidate_query.

Description

The test added in #129336 sometimes spins in its first wait_until for the whole 60 s. In Fast test that is the per-test limit, so the test is killed and the PR matrix is dropped (e.g. #129845, #129809, and twice in the merge queue); in other jobs it passes in 70-90 s instead of ~20 s (master). CIDB since 2026-11-04: 11 kills and 24 more runs over 55 s, out of 1059.

Root cause: stage 1 waits for last_successful_update_time > t0 to see the reload done by the first periodic check. With LIFETIME(1) that check can run in the same wall-clock second as the initial load, and last_successful_update_time is a DateTime, so it stays equal to t0. Later checks see an unchanged invalidate result and never reload again, so the condition never becomes true.

Change: wait for query_count = 0 instead. A reload publishes a new dictionary object whose counter starts at 0, while the initial dictGet made the old one 1, so the condition does not depend on wall-clock seconds.

Validation (debug build, 120 runs per arm with random start offsets and a query_log race detector): the original test stalled in all 5 runs where the reload landed in the same second (71-73 s), the fixed test passed all 3 such runs in under 18 s and all 120 runs in under 23 s. --test-runs 50 with and without randomization: 100/100 OK. With the #129336 fix removed, the fixed test still fails (on 26.10.2.103: 3/3 on the dictHas line).


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

Version info

  • Merged into: 26.11.1.1594-master (included in 26.11 and later)

Stage 1 waited for `last_successful_update_time > t0` to observe the reload
done by the first periodic check. With `LIFETIME(1)` the next check can be
due immediately, so the 5 s periodic updater tick may run it in the same
wall-clock second as the initial load. `last_successful_update_time` is a
`DateTime` (seconds), so it then stays equal to `t0`, and every later check
returns the same invalidate query result and does not reload again: the
loop spins until its 60 s deadline. In Fast test that is the per-test limit,
so the test is killed and the whole PR matrix is dropped; elsewhere it passes
in 70-90 s instead of ~20 s.

Wait for `query_count = 0` instead: a reload publishes a new dictionary object
whose counter starts at 0, while the initial `dictGet` made the old one 1.

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

groeneai commented Nov 7, 2026

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 of the diff: 0 findings.

Checked: the initial dictGet counts on the original FLAT object (FlatDictionary::getItemsImpl), a reload publishes a clone() whose query_count starts at 0 and whose source keeps the stored invalidate query response, so stages 2 and 3 start from the same state as before.

Session id: cron:clickhouse-review-slot-10:20261107-033000

@groeneai

groeneai commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 120 runs of the original test with random 0-5 s start offsets and a query_log detector for "first periodic reload finished in the same second as the initial load": all 5 detected races stalled (71.6-72.5 s, 56-57 stage-1 polls), all other runs finished in at most 22.2 s.
b Root cause explained? Yes. LIFETIME(1) lets the first periodic check (which always reloads) run in the same second as the initial load; last_successful_update_time is a DateTime, so it stays equal to t0, and no later check reloads (unchanged invalidate result), so > t0 never becomes true.
c Fix matches root cause? Yes. Stage 1 now waits for query_count = 0: the reload publishes a new dictionary object whose counter starts at 0 (the initial dictGet made it 1). No bound widened, no tag added.
d Test intent preserved / new tests added? Yes. Stages 2 and 3 are unchanged. With the #129336 fix removed the test still fails: debug server aborts on the LOGICAL_ERROR, release 26.10.2.103 fails 3/3 on the dictHas line. Test-only change.
e Both directions demonstrated? Yes, same binary: original 5/5 races stalled, fixed 0/3 races stalled, 120/120 runs under 23 s.
f Fix is general across code paths? Yes. The two other tests reading last_successful_update_time (05218, 03701) reload on every check, so their timestamp advances on the next tick; no other test reads it.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test oracle). --test-runs 50 with randomized settings: 50/50 OK.
h Backward compatible? (maintainer-approved exception only) N/A, test-only.
i Invariants and contracts preserved? Yes. Stage 2 still starts after the first-check reload is published, so row 2 is not in it and the next check compares against the stored response, as before.

Session id: cron:clickhouse-impl-slot-4:20261107-010200

@groeneai

groeneai commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

cc @vdimir, could you review this and add the can be tested label so CI runs? The first wait_until in your new 05457 test never succeeds when the first periodic reload lands in the same second as the initial load (last_successful_update_time is a DateTime), so it now waits for query_count = 0 on the reloaded dictionary object instead.

@clickhouse-gh

clickhouse-gh Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1e206e5]

Summary: ✅


AI Review

Summary

Replaces the timestamp-based reload wait in 05457_dictionary_remote_clickhouse_invalidate_query with the new dictionary object's query_count reset, removing the same-second timestamp ambiguity while preserving the invalidation assertions. No actionable findings. The test passed in 21.11 seconds in the PR's Fast test report.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 7, 2026
@clickhouse-gh clickhouse-gh Bot added can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 7, 2026
@vdimir
vdimir added this pull request to the merge queue Nov 7, 2026
@vdimir vdimir self-assigned this Nov 7, 2026
Merged via the queue into ClickHouse:master with commit 66b092b Nov 7, 2026
380 of 381 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 7, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 7, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 7, 2026
Backport #129879 to 26.9: Fix flaky test 05457_dictionary_remote_clickhouse_invalidate_query
clickhouse-gh Bot added a commit that referenced this pull request Nov 7, 2026
Backport #129879 to 26.8: Fix flaky test 05457_dictionary_remote_clickhouse_invalidate_query
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 7, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-dictionary Dictionaries (in-memory key-value, periodically refreshed from sources). and removed comp-testing Test content only (no production code). labels Nov 22, 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-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport v26.8-must-backport v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants