: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(clickhouse): stop capturing read timeouts in partition probe (#117425)
posthog[bot]49fe250ba6ac
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.pyindex 32095f6fdfeb..756b630d5396 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@@ -1236,12 +1236,17 @@ def _get_partition_settings(except ClickHouseError as e:# Partitioning is a best-effort optimization; any failure here degrades# to default partitioning. A transient rate-limit/gateway response from- # the source, or a blip reaching our own egress proxy, isn't actionable- # on our side, so don't add error-tracking noise for it. clickhouse-connect- # wraps the proxy failure in the ClickHouseError caught here, so it never- # reaches the shared classification in `_handle_import_error`.+ # the source, a read timeout from a slow or cold-starting source host, or a+ # blip reaching our own egress proxy, isn't actionable on our side, so don't+ # add error-tracking noise for it. clickhouse-connect wraps the proxy failure+ # in the ClickHouseError caught here, so it never reaches the shared+ # classification in `_handle_import_error`.message = str(e)- if not _is_transient_http_response(message) and not is_transient_egress_proxy_error(message):+ if (+ not _is_transient_http_response(message)+ and "Read timed out" not in message+ and not is_transient_egress_proxy_error(message)+ ):capture_exception(e)logger.debug(f"_get_partition_settings: failed: {e}")return Nonediff --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.pyindex e82edd5b9fc1..bd69bce70055 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@@ -909,14 +909,24 @@ class TestGetPartitionSettings:def _logger(self):return MagicMock()- def test_unexpected_error_is_captured(self):+ @parameterized.expand(+ [+ ("unexpected_error", "Code: 62. DB::Exception: Syntax error", True),+ (+ "read_timeout",+ "HTTPSConnectionPool(host='ch.example.com', port=8443): Read timed out. (read timeout=120)",+ False,+ ),+ ]+ )+ def test_falls_back_and_captures_only_actionable_errors(self, _name, message, should_capture):client = MagicMock()- client.query.side_effect = ClickHouseError("Code: 62. DB::Exception: Syntax error")+ client.query.side_effect = ClickHouseError(message)with patch.object(ch_module, "capture_exception") as mock_capture:assert _get_partition_settings(client, "db", "t", self._logger()) is None- mock_capture.assert_called_once()+ assert mock_capture.called is should_captureclass TestGetRowsBatching: