: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(postgres): treat Supavisor's :einval socket drop as a transient retry (#126135)
Tom Owers720bd02aebfc
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.pyindex 852c6b7af60e..802263936b0c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.py@@ -437,6 +437,11 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (# "(authenticated)" wrapper would be too broad: a non-:closed "Internal error (authenticated): ..."# could be a permanent pooler/protocol failure that should surface immediately, not be retried.#+# ":einval" is the same shape with a different Erlang reason: gen_tcp returns it (POSIX EINVAL,+# "invalid argument") when a socket operation is attempted on a connection the port has already+# torn down — the same dead-backend-socket condition as ":closed", just raised on whichever side of+# the race loses after the peer closes. A fresh reconnect recovers the same way.+## Neon's own compute-side WAL relay ("walsender") surfaces the same generic XX000 InternalError_# when it loses connectivity to a safekeeper — the storage-tier peer that actually holds the WAL,# since a Neon compute doesn't keep it locally: "[walsender] Failed to read WAL (...): failed to@@ -449,6 +454,7 @@ _POOLER_CONNECTION_DROPPED_ERROR_SUBSTRINGS = ("echeckoutretries","echeckouttimeout","internal error (authenticated): :closed",+ "internal error (authenticated): :einval","failed to connect to safekeeper",)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.pyindex 6fb37afbb5a6..f867ce66fdfd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py@@ -2733,6 +2733,10 @@ class TestIsConnectionDroppedError:# error code, so it's matched on the full phrase including the ":closed" reason; same# transient class as the pooler drops above and recovers on reconnect.psycopg.errors.InternalError_("Internal error (authenticated): :closed"),+ # Same Supavisor pooler-drop shape, but raised with Erlang's ":einval" (POSIX EINVAL)+ # reason instead of ":closed" — gen_tcp returns it when an operation hits a backend+ # socket the pooler has already torn down. Same transient class; recovers on reconnect.+ psycopg.errors.InternalError_("Internal error (authenticated): :einval"),# Supavisor reports a transient timeout reaching the upstream backend as a# ConnectionFailure (08006, an OperationalError) carrying the Erlang-tuple reason# "{:error, :etimedout}" — a transient drop the in-process recovery must catch.