Repository navigation
Add timeout to 02889_file_log_save_errors polling loop - #101367
alexey-milovidov merged 10 commits into
Conversation
|
Pre-PR Validation Gate (Session cron:clickhouse-ci-task-worker:20260331-111500) a) Deterministic repro? The failure is a timeout — the test hangs indefinitely when the FileLog background thread is delayed. The infinite loop IS the bug (no timeout = guaranteed hang under slow conditions). Under normal conditions, the test completes in ~2.8s, but TSAN overhead (20x) can push this beyond CI's test timeout. b) Root cause explained? The c) Fix matches root cause? Yes — adding a 120-second timeout directly addresses the unbounded wait. The timeout is generous enough for TSAN (test completes in ~2.8s on debug, so even 40x overhead = 112s fits within 120s). If the timeout IS reached, it means a real engine issue, and the error message makes diagnosis straightforward. d) Test intent preserved? The test still verifies that FileLog with e) Both directions demonstrated? ✅ Without fix: the test hangs indefinitely under slow conditions (demonstrated by the CI failures in CIDB). With fix: 50/50 passes with full randomization locally. |
|
cc @antaljanosbenjamin — could you review this? It adds a 120-second timeout to the FileLog test's polling loop to prevent infinite hangs under TSAN/MSAN overhead, following the same pattern from |
|
Workflow [PR], commit [5c3f9c5] Summary: ✅ AI ReviewSummaryThis PR replaces the flaky asynchronous Final VerdictStatus: ✅ Approve |
|
@groeneai this doesn't actually fixes the issue, just turns it into a different error. Maybe let's reduce the number of errors. |
The test had an infinite `while true; do sleep 1; done` loop waiting for exactly 20 error records from a FileLog → Materialized View pipeline. Under TSAN/MSAN builds or resource-constrained Fast test runners, the FileLog background thread can be significantly delayed, causing the test to hang until the CI runner kills it after the test timeout. Replace the unbounded loop with a 120-second timeout, following the same pattern used in 02968_file_log_multiple_read.sh. The test data is tiny (40 records total), so 120 seconds provides generous headroom even under heavy sanitizer overhead. On failure, the timeout now produces a clear error message and properly cleans up tables and files. Closes ClickHouse#101334 Co-Authored-By: Claude Opus 4.6 <[email protected]>
As suggested by @antaljanosbenjamin: the timeout approach just turns the hang into a different error. Reducing the error count (3 per file instead of 10) addresses the actual issue — less data for the FileLog background thread to process under TSAN/MSAN overhead. The test still exercises: multi-file reading, error capture with handle_error_mode='stream', MV error routing, and correct output ordering. The timeout is kept as a safety net. Co-Authored-By: Claude Opus 4.6 <[email protected]>
174b221 to
4d0607e
Compare
|
@antaljanosbenjamin Good point — reduced the error count from 20 to 6 (3 per file instead of 10). The FileLog background thread now has 70% less data to process, which should complete well within TSAN overhead limits. The test still covers multi-file reading, error capture via Kept the 120s timeout as a safety net in case of future engine regressions, but the primary fix is the data reduction as you suggested. 50/50 passes locally with full randomization (avg 2.8s per run). |
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
|
Done — merged latest master (includes the SimSIMD SVE MSan fix from #101239) into the branch. CI should re-run with the fix included. |
The test polled `table_to_store_data` for FileLog → MaterializedView ingest with a 30-second deadline. FileLog uses exponential backoff to watch the directory (initial 500ms, max 32s — `poll_directory_watch_events_backoff_max`), so the worst-case poll interval is bigger than the test's wait window. Under sanitizer builds and shared CI runners, the backoff occasionally drifts close to that upper bound, the test fires its `wait_for_row_count` timeout before `StorageFileLog::threadFunc` runs, and the test fails. Failure data (CIDB, 30 days): 11 hits across 4 unrelated PRs, 0 master. The arm_asan_ubsan, targeted shard had a single CI run with 7 concurrent parallel-test instances all hitting the timeout (test duration 38s, just over 30s) which matches the polling-backoff hypothesis exactly. Deterministic local repro: forcing `poll_directory_watch_events_backoff_init = 31000` (>30s) makes the current 30s timeout fail every time and the new 120s timeout pass with 89s of headroom. Same fix pattern as PR ClickHouse#101367 (`02889_file_log_save_errors`). Verified locally: 50/50 passes with full CI randomization (debug build). Closes ClickHouse#79788
…save-errors-timeout
The 120s ceiling was too tight: the arm_asan_ubsan flaky check explores many randomized settings, and a single combination pushed the FileLog background pipeline past 120s while the other ~50 runs finished in ~14s. The bounded timeout still prevents the original infinite hang; 300s just gives the worst-case randomization room to complete. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101367&sha=ecaa39e85888302e6059c6f2f300cbbe3700c815&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20flaky%20check%29
The wait loop used exact equality (`!= 6`), so if the FileLog background thread ever produced more than 6 error records (e.g. duplicate read or retry), the loop could only exit via the 300s timeout — turning a clean reference-comparison mismatch into a slow, opaque timeout. Switch to a lower-bound check (`-lt 6`): the loop exits as soon as we have at least 6 records, and any overshoot is then caught immediately by the final `SELECT ... FROM log_errors ORDER BY file, record` against the reference file. Failures become fast and diagnostic instead of slow. Addresses the bot review on PR ClickHouse#101367. Verified locally: 50/50 pass with the unchanged data layout (1-2s each), and an artificial 7-error overshoot now fails the reference comparison in 1s instead of timing out at 300s.
|
Addressed the bot's lower-bound suggestion: switched the polling loop from Verified locally with
Commit: 84f19e4. @antaljanosbenjamin / @Algunenano — would either of you have a moment to re-look at this? The PR has been stalled since the data-reduction commit on March 31; CI now shows the test is stable on master (issue #101334 was auto-closed by @alexey-milovidov on May 1 after 14 stable days), but this leftover |
…save-errors-timeout Refresh the branch against current master to re-run CI. The last CI run was on 2026-05-16; the branch was ~1 month behind. master did not touch `02889_file_log_save_errors.sh` or its reference, so the PR's changes are preserved byte-identical. The sole remaining CI failure was the master-wide `Cannot start clickhouse-server` infrastructure flake.
… gate The 300s internal timeout was dead code in flaky-check mode: tests/clickhouse-test fails any non-`long` test once total time exceeds TEST_MAX_RUN_TIME_IN_SECONDS (180s), so the harness kills the run before the 300s ceiling can ever fire. Fix the root cause instead of the ceiling: cap poll_directory_watch_events_backoff_max=1000 on the FileLog table (default is 32000), mirroring the sibling 02968_file_log_multiple_read.sh. This bounds the directory-watcher backoff to ~1s so detection stays fast even under sanitizer and parallel load, and lowers TIMEOUT back to 120s (now realistic, under the 180s gate). Test completes in ~2s locally; 15/15 pass with randomization. Addresses the clickhouse-gh[bot] review on PR ClickHouse#101367. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The test waited on a background materialized view fed by the FileLog directory watcher. Under the 50x parallel flaky check on sanitizer builds, BackgroundSchedulePool contention delayed the watcher past the 120s wait, so the test hit the flaky-check 180s per-test gate and was reported as a failure. Replace the materialized view and polling loop with a single synchronous direct SELECT from the FileLog table (stream_like_engine_allow_direct_select). One read consumes every file at once, so there is no watcher thread to wait on: the test runs in ~1s and no longer depends on pool scheduling, making it parallel-safe without a no-parallel tag. Output is unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (commit 5c3f9c5)
Session id: cron:clickhouse-worker-slot-0:20260618-154100 |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 415 line(s), 15 function(s) across 139 file(s) · Details Top files
|
The wait loop used exact equality (`!= 6`), so if the FileLog background thread ever produced more than 6 error records (e.g. duplicate read or retry), the loop could only exit via the 300s timeout — turning a clean reference-comparison mismatch into a slow, opaque timeout. Switch to a lower-bound check (`-lt 6`): the loop exits as soon as we have at least 6 records, and any overshoot is then caught immediately by the final `SELECT ... FROM log_errors ORDER BY file, record` against the reference file. Failures become fast and diagnostic instead of slow. Addresses the bot review on PR ClickHouse#101367. Verified locally: 50/50 pass with the unchanged data layout (1-2s each), and an artificial 7-error overshoot now fails the reference comparison in 1s instead of timing out at 300s.
… gate The 300s internal timeout was dead code in flaky-check mode: tests/clickhouse-test fails any non-`long` test once total time exceeds TEST_MAX_RUN_TIME_IN_SECONDS (180s), so the harness kills the run before the 300s ceiling can ever fire. Fix the root cause instead of the ceiling: cap poll_directory_watch_events_backoff_max=1000 on the FileLog table (default is 32000), mirroring the sibling 02968_file_log_multiple_read.sh. This bounds the directory-watcher backoff to ~1s so detection stays fast even under sanitizer and parallel load, and lowers TIMEOUT back to 120s (now realistic, under the 180s gate). Test completes in ~2s locally; 15/15 pass with randomization. Addresses the clickhouse-gh[bot] review on PR ClickHouse#101367. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-save-errors-timeout Add timeout to 02889_file_log_save_errors polling loop
Related: #101334
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
02889_file_log_save_errorswaited on a background materialized view fed by the FileLog directory watcher. Under the 50x parallel flaky check on sanitizer builds,BackgroundSchedulePoolcontention delayed the watcher past the 120s wait, so the test exceeded the flaky-check 180s per-test gate and was reported as a failure. This is the same scheduling dependency that makes the sibling FileLog->MV tests (02968, 02026, 04031, 04242, 04257) useno-parallel.The materialized view and polling loop are replaced with a single synchronous direct SELECT from the FileLog table (
stream_like_engine_allow_direct_select). One read consumes every file at once, so there is no watcher thread to wait on: the test runs in ~1s and no longer depends on pool scheduling, making it parallel-safe without ano-paralleltag. Output and the reference file are unchanged.Verified locally (snapshot debug binary):
--test-runs 50with full randomization is 50/50 OK at ~1.2s each; injecting an extra error makes the final SELECT differ from the reference, so the test still fails fast on a real regression.Version info
26.7.1.124