Repository navigation
Conversation
Pre-PR validation gate (per task pipeline)a) Deterministic repro? Yes. After b) Root cause explained? Yes. c) Fix matches root cause? Yes. The root-cause fix is d) Test intent preserved? Yes. e) Both directions demonstrated? Yes. With
f) Fix is general? Yes. The Session: |
|
cc @alexey-milovidov — could you review this? Test-only fix for a flaky-test root cause: |
|
Workflow [PR], commit [0f93f37] Summary: ✅ AI ReviewSummaryThis PR makes Final VerdictStatus: ✅ Approve |
| cleanup() { | ||
| rm -f "${USER_FILES_PATH}"/{a,b,c}.txt | ||
| rm -f "${USER_FILES_PATH}"/{a,b,c} | ||
| rm -f /tmp/c.txt |
There was a problem hiding this comment.
Why the test uses /tmp/c.txt, if you need something outside of user_files, just use regular tmp dir (that is unique for each test)
There was a problem hiding this comment.
Good point. Done in 0f93f37: the file now lives in the per-test unique $CLICKHOUSE_TMP dir ($CLICKHOUSE_TMP/01658_outside.txt) instead of the fixed /tmp/c.txt, so concurrent runs can't collide on it, and the runner removes it afterwards.
In client mode file() rejects any path outside user_files before checking existence, so the rejection assertion is unaffected by the path. Only the local-mode read needs the contents. The ..-traversal case keeps its relative path since it only checks that escaping user_files is denied.
Verified locally via the runner: 01658 and 02843 pass 5/5 each with randomization, no /tmp/c.txt is created, and the EXIT trap still cleans up on a mid-script abort.
`01658_read_file_to_stringcolumn.sh` writes the short filenames `a`, `b`,
`c` into `user_files_path` and removes them only by manual `rm` at the
bottom of the script. The script runs under `set -e`, so any failing
query between the write and the cleanup aborts the script and leaves
those files behind. The next CI run on the same server then sees them.
`02843_context_has_expired.sql` relies on `user_files_path/a` being
absent so `SELECT 1 in (SELECT file(materialize('a')))` throws
`FILE_DOESNT_EXIST`. Once `a` is leaked, that query returns 0 instead,
the expected error never fires, and the test fails. CI shows this exact
pattern on multiple unrelated PRs over the last 90 days (the diagnostic
"Test also fails without randomized settings" matches a stuck server
state, not randomization).
This change:
- adds `trap cleanup EXIT` to `01658` so the files are removed even on
mid-script abort. Drops the now-redundant manual `rm` block.
- defensively rewrites the `file()` assertion in `02843` to use a
UUIDv4-suffixed path, so a future leak of `a` (or any other short
filename) cannot poison this test.
Verified locally: with `a` pre-seeded in `user_files_path`, pre-fix
`02843` fails 50/50; post-fix it passes 50/50.
fb2b0b6 to
a85f400
Compare
|
Rebased onto current master ( The previous run's only red was The underlying fix is still needed: master still has 01658's manual |
The "outside user_files" file was created at a fixed /tmp/c.txt, a global path shared by every concurrent run of this test. Move it into the per-test unique $CLICKHOUSE_TMP dir (which the test runner creates per test and removes afterwards) so concurrent tests cannot collide on it. In client mode file() rejects any path outside user_files before checking existence, so the rejection assertion is unaffected by the new path. Only the local-mode read actually needs the file's contents. The ".." traversal case keeps its relative path since it only tests that escaping user_files is denied. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 295 line(s), 16 function(s) across 106 file(s) · Details Top files
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Documentation entry for user-facing changes
Why
02843_context_has_expired.sqlfails sporadically on CI with:CIDB shows ~4 hits in the past 90 days, all matching the same pattern, on unrelated PRs (e.g. #100651, #101798, #104697). Crucially, the diagnostic always reports "Test also fails without randomized settings (not a randomization issue)" — so this is not a randomized-settings flake, the server is in a stuck state.
Root cause
01658_read_file_to_stringcolumn.shwrites the short filenamesa,b,cintouser_files_path(line 88 in the current script) and removes them only via the manualrmat the bottom. The script runs underset -e. Any failing query between the write and the cleanup aborts the script and leaves the files behind, where they survive across the rest of that CI session.Once
${USER_FILES_PATH}/aexists,02843's assertionSELECT 1 in (SELECT file(materialize('a')))returns 0 (the file is read successfully and1is not in the resulting Set) instead of throwingFILE_DOESNT_EXIST, and the-- { serverError FILE_DOESNT_EXIST }check trips the test.Reproduced locally:
50/50 deterministic.
Fix
Two changes:
Root cause:
01658_read_file_to_stringcolumn.shnow registerstrap cleanup EXITimmediately after sourcingshell_config.sh. The cleanup removes all files the test creates inuser_files_pathand/tmp, usingrm -fso it's idempotent. The redundant manual cleanup at the bottom of the script is removed.Defense in depth:
02843_context_has_expired.sqluses'02843_nonexistent_'||generateUUIDv4()as the path passed tofile(). The test's intent (verifying thatfile()throwsFILE_DOESNT_EXISTon a missing file) is preserved, and the assertion can no longer be poisoned by another test leaking a short filename likea.Verification
${USER_FILES_PATH}/apre-seeded:02843fails 50/50 (matches CI failure exactly).${USER_FILES_PATH}/apre-seeded:02843passes 50/50.01658trap verified to fire onset -emid-script abort (manual bash test withfalse).bash -nsyntax check on modified01658passes.Version info
26.6.1.635