Skip to content

Add configurable ClickHouse query timeout#542

Merged
ShimonSte merged 2 commits into
ClickHouse:mainfrom
ShimonSte:fix/client-query-timeout
May 17, 2026
Merged

Add configurable ClickHouse query timeout#542
ShimonSte merged 2 commits into
ClickHouse:mainfrom
ShimonSte:fix/client-query-timeout

Conversation

@ShimonSte

@ShimonSte ShimonSte commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a configurable timeout for ClickHouse client query and ping operations via a new SQL config spark.clickhouse.client.queryTimeout (default 60s). (#530)

Changes

  • New SQL config: spark.clickhouse.client.queryTimeout (ConfigEntry[Long], default 60000ms, defined in ClickHouseSQLConf and exposed on SparkOptions for read/write paths.
  • Core clients (NodeClient, NodesClient, ClusterClient): constructors now accept queryTimeoutMs: Long (defaulting to DEFAULT_QUERY_TIMEOUT_MS = 60000L, preserving prior behavior) and propagate it to client.query(...).get(timeout, MS) and client.ping(timeout).
  • Spark integration: timeout is sourced from the appropriate scope at each call site:
    • Catalog / DDL / metadata paths (ClickHouseCatalog, ClickHouseTable, ClickHouseCommandRunner): read from ClickHouseHelper.clientQueryTimeoutMs (driver-side SQLConf).
    • Read / write job paths (ClickHouseRead, ClickHouseReader, ClickHouseWrite, ClickHouseWriter): read from scanJob.readOptions.clientQueryTimeout / writeJob.writeOptions.clientQueryTimeout, which are serialized into the job description and safe on executors.
  • Replicated across spark-3.3, spark-3.4, spark-3.5, spark-4.0.

@ShimonSte ShimonSte changed the title 14zxszxfdgdfix: add configurable ClickHouse query timeout Add configurable ClickHouse query timeout May 6, 2026
@ShimonSte ShimonSte marked this pull request as draft May 6, 2026 14:38
@ShimonSte ShimonSte force-pushed the fix/client-query-timeout branch 2 times, most recently from e641928 to 37653b1 Compare May 6, 2026 15:04
@ShimonSte ShimonSte force-pushed the fix/client-query-timeout branch from 37653b1 to 09d2733 Compare May 7, 2026 06:37
@ShimonSte ShimonSte marked this pull request as ready for review May 7, 2026 06:45
@ShimonSte ShimonSte requested review from BentsiLeviav and mzitnik May 7, 2026 06:45
@BentsiLeviav

Copy link
Copy Markdown
Contributor

@ShimonSte, before we review this, I saw you extended the repo's docs (which is deprecated). Can you add here the link to the docs PR covering this?

@ShimonSte

Copy link
Copy Markdown
Contributor Author

@ShimonSte, before we review this, I saw you extended the repo's docs (which is deprecated). Can you add here the link to the docs PR covering this?

The update to the docs were done because our tests will fail if we introduce a new conf and not mention it in the documentation in the repo.

I haven't opened the PR for the documentation yet since I introduced the old timeout behavior in the open PR and I do not want to tie the publish of the docs PR with a new Spark version.
I have a meeting with @mzitnik tomorrow, Hopefully we get to merge the docs PR very soon and i will open a new PR regarding the new timeout behavior.

assert(nodeSpec.database === "testing")
assert(nodeSpec.options.get("ssl") === "true")
}

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.

Maybe I have missed. Should we run a test to verify our default timeout value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could, I'll add it.

@ShimonSte ShimonSte requested a review from mzitnik May 17, 2026 15:16
@ShimonSte ShimonSte merged commit 3feeb1f into ClickHouse:main May 17, 2026
101 checks passed
@ShimonSte ShimonSte deleted the fix/client-query-timeout branch May 17, 2026 15:34
ShimonSte added a commit that referenced this pull request Jun 22, 2026
Document under [Unreleased]:
- Added: top-N pushdown (#543), configurable query timeout (#542)
- Fixed: use_time_zone option (#548), nested VariantType via Arrow (#541),
  filter-expr quoting (#538), useNullableQuerySchema moved to catalog (#516)

Also fix the [Unreleased] compare link (v0.10.0...HEAD) and add the
missing [0.10.0] tag link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants