Skip to content

Fix flaky 02572_query_views_log_background_thread - #114694

Closed
Fgrtue wants to merge 1 commit into
masterfrom
fix-flaky-02572_query_views_log_background_thread
Closed

Fgrtue wants to merge 1 commit into
masterfrom
fix-flaky-02572_query_views_log_background_thread

Conversation

@Fgrtue

@Fgrtue Fgrtue commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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

Failure in Stateless tests (amd_msan, WasmEdge, parallel, 2/3).

@Fgrtue
Fgrtue requested a review from pufit August 13, 2026 20:20
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8679b1a]

Summary: ✅


AI Review

Summary

This PR inverts the elapsed-time guard in 02572_query_views_log_background_thread so the early "not direct flush" probe runs only on fast inserts, with the goal of avoiding spurious output once the background Buffer flush has already completed. The direction is right, but the fix is still timing-racy because it compares whole seconds against an 8-second flush threshold, so I do not think this removes the flake reliably yet.

Missing context / blind spots
  • ⚠️ The PR body links the Stateless tests (amd_msan, WasmEdge, parallel, 2/3) report from PR #110892, but that job's job.log shows 02572_query_views_log_background_thread passing ([ OK ] 28.33 sec.). I could not verify that linked report as the actual reproducer for this flake.
Findings
⚠️ Majors
  • [tests/queries/0_stateless/02572_query_views_log_background_thread.sh:25] The CI fix still depends on whole-second timing even though the Buffer background flush is armed at 8 seconds. An insert that returns at 6.x seconds is rounded down to 6, so the probe still runs; on a busy runner the extra clickhouse-client round trip can then cross the normal flush point and print 1 from an ordinary asynchronous flush, reproducing the same false-positive failure.
    Suggested fix: measure elapsed time with sub-second precision (date +%s%N is already used in other stateless shell tests) or increase the safety margin so the probe only runs when there is clearly enough headroom before a normal background flush can complete.
Tests
  • ⚠️ Please attach a focused repro or updated CI evidence that keeps the insert near the threshold and shows the probe can no longer observe a normal background flush. The linked report does not demonstrate this test failing, so the current evidence does not prove the flake is gone.
Final Verdict

Changes requested: the guard inversion narrows the race, but it does not remove it while the probe still relies on second-level timing against an 8-second flush threshold.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 13, 2026
@Fgrtue Fgrtue changed the title Fix Fix flaky 02572_query_views_log_background_thread Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8679b1aa4 with master 173adb014 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 692.69 MiB 689.68 MiB -3.02 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline.

Job report

@Fgrtue
Fgrtue force-pushed the fix-flaky-02572_query_views_log_background_thread branch from 03f90c7 to 8679b1a Compare August 14, 2026 10:36
${CLICKHOUSE_CLIENT} --query="insert into buffer_02572 values (1);"

if [ $(( $(date +%s) - start )) -gt 6 ]; then # clickhouse test cluster is overloaded, will skip
if [ $(( $(date +%s) - start )) -le 6 ]; then # if the insert was slow (overloaded runner), the background flush may already be done, so skip the check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still leaves the flake window open because the guard uses date +%s, which truncates to whole seconds, while this Buffer is configured to background-flush after 8 seconds. If the insert returns at something like 6.8s, the expression still evaluates to 6, so we run the probe even though there is only about a second of slack left. On the same overloaded runners we are trying to avoid, the extra clickhouse-client round trip can easily push that SELECT past the normal 8s flush point and print 1 from a regular background flush, so the test still fails spuriously.

Please switch this check to sub-second timing (for example date +%s%N, which other stateless shell tests already use) or otherwise add a wider safety margin before running the "not direct" probe.

@Fgrtue

Fgrtue commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

I see the test haven't failed for 3 weeks. And since there is no report anymore about the failed test, I am closing this pull request, as I cannot verify the root cause. Will get back to it if failures arise again.

@Fgrtue Fgrtue closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant