From bb766228e6d4d03623cdbb42def6d15f9f561b6a Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Thu, 14 May 2026 20:58:08 +0800 Subject: [PATCH] fix: use SELECT 1 for ClickHouse connection test and check response status --- crates/dbx-core/src/db/clickhouse_driver.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/dbx-core/src/db/clickhouse_driver.rs b/crates/dbx-core/src/db/clickhouse_driver.rs index 005f62240..d19410cd2 100644 --- a/crates/dbx-core/src/db/clickhouse_driver.rs +++ b/crates/dbx-core/src/db/clickhouse_driver.rs @@ -71,12 +71,16 @@ async fn ch_query(client: &ChClient, sql: &str, database: Option<&str>) -> Resul } pub async fn test_connection(client: &ChClient) -> Result<(), String> { - let url = format!("{}/ping", client.base_url); + let url = format!("{}/?query=SELECT%201", client.base_url); let req = build_request(client, client.http.get(&url)); - with_connection_timeout("ClickHouse", async { + let resp = with_connection_timeout("ClickHouse", async { req.send().await.map_err(|e| format!("ClickHouse connection failed: {e}")) }) .await?; + if !resp.status().is_success() { + let body = resp.text().await.unwrap_or_default(); + return Err(format!("ClickHouse error: {body}")); + } Ok(()) }