Skip to content

Fix flaky test 02789_filesystem_cache_alignment - #108968

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-02789-filesystem-cache-alignment-timeout
Jul 1, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-02789-filesystem-cache-alignment-timeout

Conversation

@groeneai

@groeneai groeneai commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

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

...

Description

02789_filesystem_cache_alignment intermittently fails with a 600s per-test
timeout, predominantly on Stateless tests (amd_tsan, s3 storage, sequential).

Root cause: the test builds an expensive derived view over
system.remote_data_paths (a full metadata walk over all disks, arrayJoin of
the cache paths, joined to system.filesystem_cache_log) as a SQL string and
re-evaluates it for every assertion. Counting QueryFinish rows in query_log,
the original test scans system.remote_data_paths 7 times and
system.filesystem_cache 4 times per run. Under thread fuzzer each scan is slow,
so the repeated evaluation pushes total runtime just over the 600s hard per-test
limit. The CI debug log of a timed-out run shows the test reaching its last
echo OK right at the 600s mark, i.e. it is not hung, just doing the same heavy
work many times.

Fix: materialize each derived view into a Memory table once and read from it in
the subsequent assertions. This reduces the remote_data_paths walk from 7x to
1x and the filesystem_cache scan from 4x to 1x. The test output is unchanged
(byte-for-byte identical to the existing .reference), and all checks still
exercise the same conditions.

Verified locally against an S3 (MinIO) backed server: output identical to the
reference across repeated runs, and query_log confirms the scan counts drop
from 7/4 to 1/1.

Version info

  • Merged into: 26.7.1.393 (included in 26.7 and later)

The test re-derived an expensive view over system.remote_data_paths
(a full metadata walk over all disks) for every assertion: 7 times for
the file-segment checks and 4 more for the filesystem_cache join. Under
thread fuzzer each scan is slow, so the repeated evaluation pushed the
test over the 600s per-test timeout (seen on amd_tsan, s3 storage runs).

Materialize each derived view into a Memory table once and read from it
in the assertions. This cuts the remote_data_paths walk from 7x to 1x
and the filesystem_cache scan from 4x to 1x, keeping the test output
byte-for-byte identical.

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes (structural, not settings-dependent). The timeout is caused by re-evaluating the expensive system.remote_data_paths view 7x + the filesystem_cache join 4x. Confirmed on an S3 (MinIO) backed server via query_log: baseline does 7 remote_data_paths scans / 4 filesystem_cache scans per run, every run.
b Root cause explained? The test stores an expensive derived view (full system.remote_data_paths metadata walk over all disks, arrayJoin of cache paths, joined to filesystem_cache_log) as a SQL string and re-evaluates it for every assertion. Under thread fuzzer each scan is slow; 7 remote_data_paths + 4 filesystem_cache evaluations push total runtime just over the 600s hard per-test limit. A timed-out CI debug log shows the test reaching its final echo OK right at the 600s mark, i.e. not hung, just repeating heavy work. The long/deadlock/race tags do NOT extend the timeout (clickhouse-test uses an unconditional proc.wait(args.timeout), default 600), so the only fix is reducing actual runtime.
c Fix matches root cause? Yes. Materialize each derived view into a Memory table once; the assertions read the materialized table. This directly removes the redundant scans (the runtime cost), not a symptom. No bounds widened, no no-random-* tag added, no data reduced.
d Test intent preserved? Yes. All 8 output lines are byte-for-byte identical to the existing .reference (unchanged). Every assertion still checks the same condition over the same data.
e Both directions demonstrated? Effect demonstrated via query_log scan counts: baseline = 7 remote_data_paths / 4 filesystem_cache scans; fixed = 1 / 1. Output verified identical to .reference across 6 repeated runs through the real shell_config.sh path. (A wall-clock fail/pass cannot be shown deterministically on a fast local box without the CI tsan thread-fuzzer slowdown; the scan-count reduction is the deterministic proof the runtime cause is addressed.)
f Fix is general across code paths? N/A (test-only change, not a code bug).
g Fix generalizes across inputs? N/A (test-only change, not a code bug).
h Backward compatible? N/A (test-only change, no setting/format/behavior change).
i Invariants and contracts preserved? N/A (test-only change). The two materialized derivations are deterministic after the priming SELECT + FLUSH LOGS (cache state is stable; max_size=1Gi >> data so no eviction), so materializing once also removes any drift between the previously-separate evaluations.

Session id: cron:clickhouse-worker-slot-6:20260630-171500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kssenii — could you review this? It speeds up the flaky 02789_filesystem_cache_alignment (600s timeouts on amd_tsan, s3 storage) by materializing the expensive system.remote_data_paths derived view once instead of re-evaluating it per assertion (7x -> 1x scans), keeping the reference output unchanged.

@kssenii kssenii self-assigned this Jun 30, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a291f84]

Summary: ✅


AI Review

Summary

This PR materializes the two expensive derived queries in 02789_filesystem_cache_alignment into Memory tables so the test stops re-scanning system.remote_data_paths and system.filesystem_cache on every assertion. The current script preserves the original assertions and unchanged reference output, and I did not find a remaining correctness, isolation, or evidence gap that warrants new inline comments.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — e78459d

Every 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 CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Fast test (arm_darwin) / 03988_keeper_client_autocomplete flaky (10 unrelated PRs / 0 master, 30d; macOS keeper-client teardown emits benign ENOTCONN "Socket is not connected" on stderr; this PR is a stateless test-only change to 02789, no causal link) #107438 (ours, open)
Stress test (amd_tsan) / Hung check failed, possible deadlock found chronic stress shutdown deadlock (544 PRs / 251 master / 1508 hits, 14d) #108212 (ours, merged) / #105905 (ours, open)
Stress test (arm_tsan) / Hung check failed, possible deadlock found same chronic hung-check family #108212 (ours, merged) / #105905 (ours, open)

No PR-caused failures. Session id: cron:our-pr-ci-monitor:20260630-233000

@kssenii

kssenii commented Jul 1, 2026

Copy link
Copy Markdown
Member

@groeneai merge master into current branch

@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@kssenii merged master into the branch. New head: a291f84. Net diff unchanged (only the 02789 test materialization change). CI re-running.

@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.78% 85.80% +0.02%
Functions 91.46% 91.46% +0.00%
Branches 78.31% 78.35% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 139 line(s), 43 function(s) across 44 file(s) · Details

Top files
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesChanges.h: 14 line(s), 32 function(s)
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeSeriesGroupArray.h: 10 line(s), 8 function(s)
  • src/Common/ColumnsHashing.h: 8 line(s), 2 function(s)
  • src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp: 8 line(s)
  • src/Storages/ObjectStorageQueue/ObjectStorageQueueSource.cpp: 8 line(s)

Full report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 1, 2026
Merged via the queue into ClickHouse:master with commit a00be56 Jul 1, 2026
176 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-filesystem-cache-alignment-timeout

Fix flaky test 02789_filesystem_cache_alignment
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 pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants