Repository navigation
Fix flaky 02968_file_log_multiple_read: raise wait timeout to 120s - #103602
Conversation
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
|
Pre-PR validation gate (per session protocol):
Session: cron:clickhouse-ci-task-worker:20260427-101500 |
|
cc @antaljanosbenjamin — could you review this? It's a test-only timeout fix for a flaky FileLog test (raises the polling deadline from 30s to 120s to cover FileLog's worst-case 32s exponential backoff window, same pattern as PR #101367). |
|
Workflow [PR], commit [18406d0] Summary: ✅ AI ReviewSummaryThis PR stabilizes ClickHouse Rules
Final VerdictStatus: ✅ Approve |
The 120s timeout bump alone is not sufficient to stabilise the test under heavy CI load. The default `poll_directory_watch_events_backoff_max` is 32s, and under sanitizer builds with `BackgroundSchedulePool` contention the polling cycle can genuinely drift to that upper bound. Combined with re-schedule latency the test occasionally still hits the 120s cap (4 flaky-check failures on PR ClickHouse#103602 itself: 2x amd_debug, 2x amd_asan_ubsan). Cap `poll_directory_watch_events_backoff_max` at 1s on the test's `FileLog` table so the worst-case polling cycle is bounded by 1s plus scheduling jitter, well below the 120s safety net. Verified locally: 50/50 passes with full random settings and 50/50 with `-j 8` parallel load; 100% pass under default settings (no random). CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103602&sha=d20c9edff5b37fc886d6e823a10662f36ee318bd&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 Session: cron:clickhouse-ci-task-worker:20260428-104500
|
Update — additional fix pushed ( After the 30s → 120s timeout bump landed, CI still showed 4 flaky-check failures (2× Root cause (deeper than the timeout): the default Fix: add Pre-PR validation gate:
The 120s timeout is kept as a safety net (matches 02889 pattern). Reviewer guidance: please re-run flaky check; if it's clean we're done. |
The deeper-fix attempt (commit 8cd5a2f) capped `poll_directory_watch_events_backoff_max` at 1s, but CI flaky-check still showed 1/50 failures on `Stateless tests (amd_asan_ubsan, flaky check)` at the 120s wait timeout. Local 100/100 with `-j 8` did not reproduce the issue; local `-j 50` with the ASan binary mirrors CI load and is enough to expose the root cause: - Each `FileLog` table occupies two `BackgroundSchedulePool` tasks (`DirectoryWatcherBase::watchFunc` looping on inotify and `StorageFileLog::threadFunc` blocked on `cv.wait`). - With 50 concurrent test instances, the pool sees 100+ resident tasks competing with all other test workloads on the shared schedule pool. - Under that contention the wake-up path (`watchFunc` -> `wakeUp` -> `cv.notify_one` -> `threadFunc` resumes -> `streamToViews`) can take well over 120s in tail cases, even though the polling backoff is bounded to 1s. `no-parallel` removes the contention entirely. Sequential execution gives a consistent 9.7-11.5s per run with the ASan binary (50/50 local, 25/25 in a local `--flaky-check` simulation with `--test-runs 25`). This matches the precedent set by other `FileLog` tests that share the same timing-sensitive streaming path: `02026_storage_filelog_largefile.sh` and `04031_filelog_drop_mv_no_exception.sh`. The bounded backoff added in the previous commit is preserved as defense-in-depth and the comment in `wait_for_row_count` is updated to reflect the new rationale. No changes to test logic or coverage of PR ClickHouse#58877's "multiple read in MV" fix. Verified locally: - `--test-runs 50 -j 1` on ASan: 50/50 pass, 9.70 - 11.46s per run. - `--test-runs 25 --flaky-check` on ASan: 25/25 pass, 9.60 - 11.56s. CI report on previous commit (1/50 fail @ 132.57s): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103602&sha=8cd5a2ff591de07613831b87db0795a766e88ee8&name_0=PR&name_1=Stateless%20tests%20(amd_asan_ubsan%2C%20flaky%20check)
Update —
|
| # | Question | Answer |
|---|---|---|
| a | Deterministic repro? | Yes — -j 50 ASan locally reproduces the timeout in tail cases; sequential execution does not. |
| b | Root cause explained? | Yes — BackgroundSchedulePool contention from 50 concurrent FileLog instances delays the cv.wait → streamToViews wake-up path past 120s. |
| c | Fix matches root cause? | Yes — no-parallel removes the contention directly. |
| d | Test intent preserved? | Yes — same logic, same coverage of PR #58877's "multiple read in MV" fix, and the poll_directory_watch_events_backoff_max = 1000 setting is preserved as defense-in-depth. |
| e | Both directions demonstrated? | Yes — -j 50 reproduces the failure; -j 1 and --flaky-check simulation pass cleanly. |
This matches the precedent set by other timing-sensitive FileLog tests: 02026_storage_filelog_largefile.sh and 04031_filelog_drop_mv_no_exception.sh already carry no-parallel.
— session id: cron:clickhouse-ci-task-worker:20260428-221500
The 150s warm-up loop in the test polls the destination MergeTree table waiting for the `FileLog` background thread to ingest the prepared CSV file. The default `poll_directory_watch_events_backoff_max` is 32s, and under sanitizer builds with `BackgroundSchedulePool` contention the polling cycle can drift to that upper bound. On slow runners (`ASan`+azure, `MSan`+WasmEdge) the file is occasionally not picked up within 150s and the test reports "Warm-up failed: only 0 rows consumed after 300 attempts". Looking at CIDB for the 30-day window after PR ClickHouse#102386 merged the timeout bump (2026-04-17), 12 failures still remain — all 10/12 with the same warm-up timeout signature, dominated by `Stateless tests (arm_asan_ubsan, azure, sequential)` (10 hits) and `amd_msan` (2 hits). Cap `poll_directory_watch_events_backoff_max` at 1s on the test's `FileLog` table so the worst-case polling cycle is bounded by 1s plus scheduling jitter, well below the 150s warm-up loop. Same pattern as PR ClickHouse#103602 for sister test `02968_file_log_multiple_read`. The fix preserves the test's original purpose (regression test for `DEPENDENCIES_NOT_FOUND` race when the materialized view is dropped during streaming) — only the file-detection latency is bounded, the DROP-during-streaming race window is unchanged. Verified locally: - 50/50 passes with `--no-random-settings --no-random-merge-tree-settings`. - Deterministic repro of the failure mode without the fix: with `poll_directory_watch_events_backoff_init=200000`, `poll_directory_watch_events_backoff_max=200000` (simulating a 200s polling cycle), the warm-up fails: "REPRODUCED: only 0 rows after 150s warm-up". CI report (sample failure): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102302&sha=a4cc3a4d5acd3ee9dae8860b032a8fe7b91b2dce&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20sequential%2C%202%2F2%29 Closes ClickHouse#102388 Session: cron:clickhouse-ci-task-worker:20260428-114500
The test
02968_file_log_multiple_read.shpollstable_to_store_datafor FileLog → MaterializedView ingest with a 30-second deadline inwait_for_row_count. FileLog watches its directory using exponential backoff (initial 500ms, max 32s — seepoll_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'swait_for_row_counttimeout fires beforeStorageFileLog::threadFuncruns, and the test fails.Failure data
CIDB, last 30 days: 11 failures 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) deterministically reproduces the failure with the current 30s timeout (file detected at 31s, 1s after timeout fires) and passes with the new 120s timeout (file detected at 31s, 89s of headroom).Verification
50/50 passes locally with full CI randomization (debug build).
Approach
Same fix pattern as PR #101367 (
02889_file_log_save_errors). The fix only widens the wait window — the test still asserts that all rows from the FileLog source flow through the materialized view to the destination MergeTree table.CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102192&sha=df3318c6e12376575c32003ad1ffa8d429eadc09&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20targeted%29 (PR #102192)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not applicable.
Documentation entry for user-facing changes
Version info
26.5.1.176