: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): retry transient egress-proxy gateway drops in-process (#68372)
Tom Owers508d85508217
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 145b4283fb71..5a10f97dc5bc 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@@ -104,6 +104,14 @@ _TRANSIENT_CONNECT_DROP_SUBSTRINGS = ("EOF occurred in violation of protocol","Connection reset by peer","Connection aborted",+ # The egress proxy answered our CONNECT with a transient gateway status+ # (`http.client` raises `OSError("Tunnel connection failed: <code> ...")`).+ # 502/503/504 are the proxy or its upstream being briefly unreachable or+ # overloaded, so a fresh attempt recovers. We match only these gateway+ # codes, not deterministic proxy responses like 407 (auth required).+ "Tunnel connection failed: 502",+ "Tunnel connection failed: 503",+ "Tunnel connection failed: 504",)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.pyindex d30a0b0748db..d62f2c3d08e8 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@@ -680,6 +680,13 @@ class TestIsTransientConnectDrop:"EOF occurred in violation of protocol","Connection reset by peer","('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))",+ # The exact wrapped message that reached error tracking: the egress proxy+ # returned a 502 while opening the CONNECT tunnel to a ClickHouse host.+ "Error HTTPSConnectionPool(host='h', port=8443): Max retries exceeded with url: /? "+ "(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: "+ "502 Bad gateway'))) executing HTTP request attempt 1",+ "Tunnel connection failed: 503 Service Unavailable",+ "Tunnel connection failed: 504 Gateway Timeout",],)def test_matches_transient_drops(self, message):@@ -692,6 +699,8 @@ class TestIsTransientConnectDrop:"[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2657)","Code: 516. DB::Exception: Authentication failed","HTTPDriver for https://host:8443 returned response code 404",+ # A proxy 407 is a deterministic auth-config failure, not a transient gateway blip.+ "Tunnel connection failed: 407 Proxy Authentication Required",],)def test_does_not_match_deterministic_failures(self, message):