Repository navigation
Fix flaky test_database_delta::test_snapshot_version (Spark DESCRIBE HISTORY timeout) - #109641
Conversation
test_database_delta::test_snapshot_version is chronically flaky: the get_table_versions() helper runs a read-only DESCRIBE HISTORY via execute_spark_query() without retry_on_timeout, so a single 600s attempt is consumed entirely by a transient Unity Catalog HTTP-client hang (the UC Java client has no per-request timeout, see the jstack root cause recorded in the retry mechanism added earlier). The test then fails with 'timed out after 600s'. DESCRIBE HISTORY is read-only and idempotent, so retry_on_timeout is safe: it uses the shorter 300s per-attempt budget and a fresh-JVM retry, and two attempts (600s) still fit the 900s pytest timeout. The non-idempotent INSERT calls are deliberately left un-retried. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-12:20260707-125100 |
|
cc @scanhex12 — could you review? Small test-only fix: enable the existing |
|
Workflow [PR], commit [5e22d65] Summary: ✅ AI ReviewSummaryThis PR opts the read-only Missing context / blind spots
Final Verdict
|
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 131 line(s), 4 function(s) across 18 file(s) · Details Top files
|
CI finish ledger — b0c7fcbAll CI checks passed. No failures to own.
Session id: cron:our-pr-ci-monitor:20260707-163000 |
…pshot-version-spark-retry Fix flaky test_database_delta::test_snapshot_version (Spark DESCRIBE HISTORY timeout)
Backport #109641 to 26.6: Fix flaky test_database_delta::test_snapshot_version (Spark DESCRIBE HISTORY timeout)
test_complex_table_schema and test_varchar_char_types_via_unity_catalog fail with
"subprocess.TimeoutExpired: ... bin/spark-sql ... timed out after 600 seconds".
CIDB over 30 days: 5 rows across 5 distinct PRs for this signature, 0 on master.
The Unity Catalog server accepts GET /schemas/{name} and never answers it, and the
UC Java client issues that request through java.net.http.HttpClient with no
per-request timeout, so the Spark driver parks for the whole subprocess budget.
The jstack that the test's own hang diagnostics capture 600s into the stall puts
it in the batch's first statement:
"main" ClickHouse#1 cpu=11625.96ms elapsed=600.24s WAITING (parking)
jdk.internal.net.http.HttpClientImpl.send
io.unitycatalog.client.api.SchemasApi.getSchemaWithHttpInfo(SchemasApi.java:273)
io.unitycatalog.spark.UCProxy.loadNamespaceMetadata(UCSingleCatalog.scala:399)
SupportsNamespaces.namespaceExists(SupportsNamespaces.java:98)
CreateNamespaceExec.run(CreateNamespaceExec.scala:43)
CreateNamespaceExec.run probes namespaceExists before creating anything. In the
same diagnostics both socket ends are ESTAB with Recv-Q = Send-Q = 0 for 600s
(the request was fully delivered and UC produced no response byte) while a
concurrent UC liveness probe answered in 10.7ms, so the server was serving other
requests and a fresh client converges.
Two alternatives are excluded by measurement. Ivy package resolution is not
involved: the failing run reports "0 artifacts copied, 33 already retrieved
(0kB/16ms)", because the image pre-resolves the same --packages list at build
time. Derby metastore init is not involved either: the JVM got well past
ObjectStore init.
UC is a third-party server pinned in the test image and its client constructs its
own HttpClient, so neither the handler nor a request timeout is reachable from the
spark-sql command line. The only lever the test owns is to survive the stall,
which is what ClickHouse#107133 established and ClickHouse#109641 extended to the read path.
Hence the same two-part remedy at the two measured write sites: rewrite the batch
into the idempotent form already used at the precedent site (CREATE SCHEMA IF NOT
EXISTS, CREATE TABLE IF NOT EXISTS, INSERT OVERWRITE), then pass
retry_on_timeout=True so one fresh-JVM replay is allowed. 2 x 300s fits the 900s
per-test cap from tests/integration/pytest.ini with roughly 300s of headroom; no
timeout constant changes. Both tables are named with a fresh uuid4() and hold
exactly one row, so a replay converges to identical content.
test_snapshot_version is deliberately left alone. It asserts the Delta commit
history (get_table_versions() == ["0","1","2"] and _commit_version), so INSERT
OVERWRITE would add a commit and break the assertions; making it replay-safe
needs a real restructure. That is the same boundary ClickHouse#109641 drew when it retried
only that test's read-only DESCRIBE HISTORY.
Validation. Since the UC stall cannot be forced, a temporary local injection
reported a timeout after the batch had really executed and committed, which is
the worst case for a replay: 4/4 test executions passed and each logged the
retry. Reverting exactly one edit at a time then reddens the run for the
predicted reason (SCHEMA_ALREADY_EXISTS, TABLE_OR_VIEW_ALREADY_EXISTS, and a
duplicate row breaking the column assertions), so no edit is decoration. Without
injection: 4/4 on the pristine tree and 4/4 with the fix in the same wall-clock
band, 21 passed / 3 skipped for the whole module, and 40/40 over --count 10 on
all four parameter ids.
Failing job:
https://github.com/ClickHouse/ClickHouse/actions/runs/35763632624/job/107009114425
Co-Authored-By: Claude Opus 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes the chronic flaky
test_database_delta/test.py::test_snapshot_version(timed out after 600s).Root cause: the
get_table_versions()helper runs a read-onlyDESCRIBE HISTORYthroughexecute_spark_query()withoutretry_on_timeout, so it uses a single 600s attempt. A transient Unity Catalog HTTP-client hang (the UC Java client has no per-request timeout, see the jstack root cause recorded when the retry mechanism was added) can consume that whole attempt, and the test fails withtimed out after 600s. The CI report (Integration tests amd_tsan 5/6, PR #109229) shows exactly this: the hang is inside Spark/Ivy + UC on theDESCRIBE HISTORYinvocation.Fix: pass
retry_on_timeout=Trueon this read-only call. It is idempotent, so a fresh-JVM retry is safe. This uses the shorter 300s per-attempt budget with 2 attempts (600s total), which still fits the 900s pytest timeout. The non-idempotentINSERTcalls in the same test are deliberately left un-retried.