Skip to content

Flush crash_log first in handleCrash to fix flaky test_crash_log_synchronous - #100378

Merged
alexey-milovidov merged 6 commits into
masterfrom
fix-crash-log-flush-order
Mar 29, 2026
Merged

alexey-milovidov merged 6 commits into
masterfrom
fix-crash-log-flush-order

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 22, 2026 •

Copy link
Copy Markdown
Member

In SystemLogs::handleCrash, logs are flushed sequentially in declaration order. QueryLog (index 0) was flushed before CrashLog (index 5). When both have flush_on_crash=true and the sleep_in_logs_flush failpoint is active (adding 30s per flush), the combined time of stack symbolization (250s+ on loaded ARM CI) plus query_log flush (30s) plus crash_log flush (30s) can exceed the signal handler's 303-second timeout, killing the process before crash_log is written.

Fix by flushing crash_log first since it is the most important log during a crash. Also wrap each log's handleCrash in try/catch so that a timeout in one log does not prevent flushing others.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100290&sha=7bbc2a132b1aaf5e4b723c00b1c3b7db5badc6ad&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29
#100290

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.386

…_synchronous`

In `SystemLogs::handleCrash`, logs are flushed sequentially in declaration
order. `QueryLog` (index 0) was flushed before `CrashLog` (index 5). When
both have `flush_on_crash=true` and the `sleep_in_logs_flush` failpoint is
active (adding 30s per flush), the combined time of stack symbolization
(250s+ on loaded ARM CI) plus query_log flush (30s) plus crash_log flush
(30s) can exceed the signal handler's 303-second timeout, killing the
process before `crash_log` is written.

Fix by flushing `crash_log` first since it is the most important log
during a crash. Also wrap each log's `handleCrash` in try/catch so that
a timeout in one log does not prevent flushing others.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100290&sha=7bbc2a132b1aaf5e4b723c00b1c3b7db5badc6ad&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [849e7d1]

Summary: ✅


AI Review

Summary

This PR updates SystemLogs::handleCrash to flush crash_log before other system logs and isolates per-log handleCrash failures via local try/catch, improving robustness in timeout-constrained crash handling. I did not find correctness, safety, concurrency, or compatibility issues in the change.

Missing context
  • ⚠️ No CI job logs/results were attached to this review run, so validation here is static (code + diff) only.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@alexey-milovidov

Copy link
Copy Markdown
Member Author

#100376

@Algunenano Algunenano self-assigned this Mar 23, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. And I see you fixed the sync problem with Coordination::setCurrentComponent. Nice

@clickhouse-gh

clickhouse-gh Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.20% 84.10% -0.10%
Functions 24.60% 24.30% -0.30%
Branches 76.70% 76.70% +0.00%

Changed lines: 0.00% (0/26) · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, this is a good change.

@alexey-milovidov
alexey-milovidov merged commit 8c81de7 into master Mar 29, 2026
149 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-crash-log-flush-order branch March 29, 2026 15:57
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants