Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(clickhouse): stop reporting HTTP read timeouts from duplicate-PK probe (#73621)

Tom Owersb9f28090eed0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
index a36150d3b82b..074aba21a13a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
@@ -866,10 +866,15 @@ _DUPLICATE_PK_CHECK_SETTINGS: dict[str, Any] = {
# caps before `read_overflow_mode='break'` truncates on rows — the probe
# behaving exactly as designed. Some managed servers also enforce a memory
# cap below our `max_memory_usage`, surfacing the same way.
+# - "Read timed out": the probe's `max_execution_time` only bounds server-side
+# execution, not ClickHouse Cloud's cold-resume wake-up latency or a scan
+# the server hasn't yet gotten around to capping — so the HTTP client's own
+# read timeout can fire first. Same designed fallback as the budget caps.
_EXPECTED_PROBE_FAILURE_SUBSTRINGS: tuple[str, ...] = (
"is unknown or readonly",
"MEMORY_LIMIT_EXCEEDED",
"TIMEOUT_EXCEEDED",
+ "Read timed out",
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
index 5f01888d272c..125e15408b6e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
@@ -1111,6 +1111,9 @@ class TestHasDuplicatePrimaryKeys:
"Setting optimize_aggregation_in_order is unknown or readonly",
# Server-side memory cap below our probe's max_memory_usage.
"Code: 241. DB::Exception: Query memory limit exceeded ... (MEMORY_LIMIT_EXCEEDED)",
+ # HTTP client read timeout firing before the server-side
+ # max_execution_time cap does (e.g. ClickHouse Cloud cold-resume).
+ "Error HTTPSConnectionPool(host='example.clickhouse.cloud', port=8443): Read timed out. (read timeout=120)",
],
)
def test_expected_probe_failures_not_captured(self, error_msg):