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): retry when the egress proxy hangs up mid-connect (#107498)

Tom Owersec445b233596
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 d84607373af4..ed35d3e731ca 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
@@ -166,6 +166,11 @@ _TRANSIENT_CONNECT_DROP_SUBSTRINGS = (
# 407` above, which wraps the same "Cannot connect to proxy." prefix around a deterministic
# proxy-auth response and must stay non-retryable.
"Cannot connect to proxy.', TimeoutError('timed out')",
+ # The egress proxy accepted the TCP connection but hung up before answering the CONNECT
+ # request ("ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed
+ # connection without response'))"). Same proxy-side blip as the TimeoutError case above, just
+ # a different socket-layer shape, so it gets the same in-process re-dial.
+ "Cannot connect to proxy.', RemoteDisconnected",
)
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 cadcddb7e62e..befb1f9f6d28 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
@@ -810,6 +810,11 @@ class TestIsTransientConnectDrop:
"Error HTTPSConnectionPool(host='h', port=8443): Max retries exceeded with url: /? "
"(Caused by ProxyError('Cannot connect to proxy.', TimeoutError('timed out'))) "
"executing HTTP request attempt 1",
+ # The exact wrapped message that reached error tracking: the egress proxy accepted
+ # the TCP connection but hung up before answering the CONNECT request.
+ "Error HTTPSConnectionPool(host='h', port=8443): Max retries exceeded with url: /? "
+ "(Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end "
+ "closed connection without response'))) executing HTTP request attempt 2",
],
)
def test_matches_transient_drops(self, message):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py
index ab65722fb58f..d6d9ef673b53 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py
@@ -45,6 +45,11 @@ TRANSIENT_EGRESS_PROXY_ERRORS: tuple[str, ...] = (
"Tunnel connection failed: 504",
"Cannot connect to proxy.', TimeoutError",
"Cannot connect to proxy.', NewConnectionError",
+ # Our own egress proxy accepted the TCP connection but hung up before answering the CONNECT
+ # request (`ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed
+ # connection without response'))`) — the same proxy-side blip as the TimeoutError/
+ # NewConnectionError variants above, just a different failure shape at the socket layer.
+ "Cannot connect to proxy.', RemoteDisconnected",
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py
index df119f59f4cb..2bf868a5aa8a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py
@@ -18,8 +18,19 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.err
"HTTPSConnectionPool(host='login.example.com', port=443): Max retries exceeded with url: /oauth2/token "
"(Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection "
"object at 0x7f>: Failed to establish a new connection: [Errno 111] Connection refused')))",
+ "Error HTTPSConnectionPool(host='h', port=8443): Max retries exceeded with url: /? "
+ "(Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed "
+ "connection without response'))) executing HTTP request attempt 2",
+ ],
+ ids=[
+ "tunnel_429",
+ "tunnel_502",
+ "tunnel_503",
+ "tunnel_504",
+ "proxy_connect_timeout",
+ "proxy_connect_refused",
+ "proxy_connect_remote_disconnected",
],
- ids=["tunnel_429", "tunnel_502", "tunnel_503", "tunnel_504", "proxy_connect_timeout", "proxy_connect_refused"],
)
def test_matches_transient_egress_proxy_failures(message: str) -> None:
assert is_transient_egress_proxy_error(message)