Skip to content

Fix timeout in test_check_database_unity by batching Spark queries - #102649

Merged
antonio2368 merged 1 commit into
masterfrom
fix-database-delta-unity-timeout
Apr 14, 2026
Merged

antonio2368 merged 1 commit into
masterfrom
fix-database-delta-unity-timeout

Conversation

@antonio2368

@antonio2368 antonio2368 commented Apr 14, 2026 •

Copy link
Copy Markdown
Member

Fix timeout in test_check_database_unity by combining schema creation, table creation,
and insert queries into a single execute_multiple_spark_queries call instead of
multiple execute_spark_query calls. Each call starts a new JVM, and the cumulative
startup time was causing the test to exceed the timeout.

Master CI failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=66a2a0e7f28b36ec3f9da7f3b0b67e6926a67b8e&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%202%2F6%29

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.927

Combine schema creation, table creation, and insert queries into a single
`execute_multiple_spark_queries` call to avoid multiple slow JVM startups
that caused the test to time out.

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

clickhouse-gh Bot commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3d1b435]

Summary: ✅


AI Review

Summary

This PR updates test_check_database_unity to batch schema creation, table creation, and inserts into one execute_multiple_spark_queries call, reducing repeated Spark JVM startup overhead that caused timeout-related CI instability. I did not find correctness, safety, performance, or compliance issues in the proposed test-only change.

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 ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 14, 2026
@antonio2368
antonio2368 force-pushed the fix-database-delta-unity-timeout branch from 737d7b4 to 3d1b435 Compare April 14, 2026 11:04
@antonio2368
antonio2368 added this pull request to the merge queue Apr 14, 2026
Merged via the queue into master with commit cc4e3ad Apr 14, 2026
162 checks passed
@antonio2368
antonio2368 deleted the fix-database-delta-unity-timeout branch April 14, 2026 14:20
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 14, 2026
pull Bot pushed a commit to infdahai/ClickHouse that referenced this pull request May 14, 2026
The chronic flaky test `test_database_delta::test_check_database_unity`
times out on `Integration tests (arm_binary, distributed plan, 4/4)`
when the Spark JVM hangs between metastore initialization and actual
query execution. PR ClickHouse#102649 (merged 2026-04-14) batched 7 sequential
Spark invocations into one, dropping the failure rate to 2 master hits
in 30 days, but a residual hang remains and we currently have no data
to localize it: on `subprocess.TimeoutExpired` the Spark JVM is killed
by SIGKILL, so `stdout`/`stderr` are truncated to whatever Spark logged
before the hang point and the existing `uc.log` tail is not enough to
say where the JVM is stuck.

Add a `_capture_spark_hang_diagnostics` helper that runs after the
existing log capture in the exception handler of `execute_spark_query`
and collects three pieces of state from inside the test container:

  1. `jstack` thread dump of every running `org.apache.spark` JVM —
     shows exactly where the JVM is stuck during the hang.
  2. Unity Catalog HTTP liveness probe on `http://localhost:8080` —
     shows whether UC is responsive while Spark is hung.
  3. `ss -tnp` snapshot of sockets matching `:8080` or `java` — shows
     whether Spark holds open sockets to UC at the moment of the hang.

Each diagnostic is wrapped in its own `try`/`except` so a failure in
one does not prevent collection of the others, and all `exec_in_container`
calls use a short timeout (15-30 s) so the diagnostics cannot extend the
test failure time noticeably. The helper runs only on the already-failing
path so it cannot make a passing test fail.

This is diagnostic-only — it does not fix the residual hang. The data it
captures will let the next master hit be localized to a specific stuck
thread or UC RPC instead of "Spark stopped logging".

Tracked in worker task 2026-05-12-ci-p2-testdatabasedeltatestcheckd.
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.

2 participants