Repository navigation
Fix flaky test test_dictionaries_postgresql::test_invalidate_query - #109390
Conversation
The test drives dict0, a config-based PostgreSQL dictionary with LIFETIME(1) and an invalidate_query, and asserts that changing a row other than the invalidate row (id != 0) does not reload the dictionary. SYSTEM RELOAD DICTIONARY performs a forced full reload but does not run the invalidate query, so the stored invalidate response is left empty. The first periodic check after the forced reload therefore always sees a "modified" source and reloads once more. If that follow-up reload lands after the test has changed the other rows (value * 2 WHERE id != 0), the dictionary picks up value 2 for id = 1 and the "no update should happen" assertion fails with '2' == '1'. On slow sanitizer / old-analyzer runs the periodic check (every 5s) lines up with the fixed sleep(5) window often enough to fail intermittently. It never fails on master. Wait for the invalidate baseline to settle (last_successful_update_time stops advancing across a full check period) after each reload, and verify the "no update" case directly by asserting last_successful_update_time does not advance. This drains the guaranteed post-forced-reload reload before the assertion and keeps the original intent: a change to the invalidate row triggers a reload, a change to other rows does not. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Verification: reproduced deterministically both directions; Session id: cron:clickhouse-worker-slot-4:20260704-032300 |
|
cc @vdimir - could you review? Small test-only fix for the flaky |
|
Workflow [PR], commit [01abbd0] Summary: ✅ AI ReviewSummaryThis PR makes Missing context / blind spots
Final Verdict✅ No blockers found in the current diff. |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 326 line(s), 27 function(s) across 16 file(s) · Details Top files
|
CI finish ledger — 01abbd0Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
No failed checks on this commit. Session id: cron:our-pr-ci-monitor:20260704-193000 |
…-test-invalidate-query-postgresql Fix flaky test test_dictionaries_postgresql::test_invalidate_query
|
@alexey-milovidov could you apply Failing run: Why the pick is trivial:
Where the fix is present there are no failures in 90 days: master 0/12924 runs, 26.7 0/867, 26.8 0/481. Where it is absent: 26.6 1/1194, and 26.5 had 2 before it retired. One label is enough. 26.7 and 26.8 already contain the merge commit, so This is test-only CI noise, so it is low priority. If you would rather leave 26.6 as it is, that is fine, just say so and I will close it out. |
Related: #109367
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes flaky
test_dictionaries_postgresql/test.py::test_invalidate_query, reported by @serxa on PR #109367.Where it was seen: the failure is not caused by #109367 (Scheduler-only change). It reproduces across 8 unrelated PRs in 30 days, 0 times on master, almost always on slow builds (
amd_asan_ubsan, db disk, old analyzerandamd_msan). Example failing run: Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6) on #109367. Assertion:test.py:385 AssertionError: assert '2\n' == '1\n'.Root cause.
dict0is a config-based PostgreSQL dictionary withLIFETIME(1)and aninvalidate_query.SYSTEM RELOAD DICTIONARYdoes a forced full reload but does not run the invalidate query, so the stored invalidate response is left empty. The first periodic check after the forced reload therefore always sees a "modified" source (empty stored response vs the real value) and reloads once more. If that follow-up reload lands after the test has changed the other rows (value * 2 WHERE id != 0), the dictionary picks upvalue = 2forid = 1and the "no update should happen" assertion fails. The periodic check runs every 5s, so on slow sanitizer / old-analyzer builds it lines up with the fixedsleep(5)window often enough to fail.This is a test timing issue, not a product bug: a forced reload must fully reload, and
invalidate_queryis a best-effort optimization (an extra reload returns fresher data, never wrong data).Fix. After each reload, wait for the invalidate baseline to settle (
last_successful_update_timestops advancing across a full check period), which drains the guaranteed post-forced-reload reload before the assertion. The "no update should happen" case is then verified directly by assertinglast_successful_update_timedoes not advance. The original intent is preserved: a change to the invalidate row (id = 0) still triggers a reload, and a change to other rows still does not.Verified locally on a debug build: reproduced the spurious reload deterministically without the settle step and confirmed it disappears with it;
test_invalidate_querythen passed 25/25 runs and the fulltest_dictionaries_postgresql/test.pysuite passed with no regressions.