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(warehouse): keep postgres pooler checkout-timeout retryable (#69874)

Tom Owers8b3742a04636
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.py
index 3018e4a8a716..74d813e24983 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
@@ -233,7 +233,11 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (
# - ECHECKOUTRETRIES ("failed to check out a connection after multiple retries"): the pooler
# couldn't hand us a backend connection after retrying internally — its pool was momentarily
# exhausted or every backend was busy. A slot frees the moment another session returns one.
-# Both are the same transient class as the libpq drops above and recover on reconnect. Genuine
+# - ECHECKOUTTIMEOUT ("unable to check out connection from the pool after <n>ms in Transaction
+# mode"): the transaction-mode sibling of ECHECKOUTRETRIES — the pooler assigns a backend per
+# transaction and couldn't check one out before its checkout timeout elapsed because the pool
+# was saturated for the whole window. Clears the moment a session returns a connection.
+# These are all the same transient class as the libpq drops above and recover on reconnect. Genuine
# XX000 internal errors (data corruption, etc.) carry a different code and stay non-recoverable.
#
# Supavisor also surfaces a backend socket that closed mid-session — after the client authenticated
@@ -246,6 +250,7 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (
_POOLER_CONNECTION_DROPPED_ERROR_SUBSTRINGS = (
"edbhandlerexited",
"echeckoutretries",
+ "echeckouttimeout",
"internal error (authenticated): :closed",
)
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.py
index 127d304ea133..38ccb890c655 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
@@ -1190,6 +1190,12 @@ class TestIsConnectionDroppedError:
# retrying internally. Same transient pooler class as EDBHANDLEREXITED; recovers on
# reconnect once a session returns a connection to the pool.
psycopg.errors.InternalError_("(ECHECKOUTRETRIES) failed to check out a connection after multiple retries"),
+ # Transaction-mode sibling of ECHECKOUTRETRIES: Supavisor couldn't check out a backend
+ # from the pool before its checkout timeout elapsed. Same transient pooler-saturation
+ # class, also an XX000 InternalError_, matched on the "(ECHECKOUTTIMEOUT)" code.
+ psycopg.errors.InternalError_(
+ "(ECHECKOUTTIMEOUT) unable to check out connection from the pool after 60000ms in Transaction mode"
+ ),
# Supavisor loses the backend socket mid-session (idle cull, restart, failover) and, once
# the client is past auth, surfaces it as an XX000 InternalError_ "Internal error
# (authenticated): :closed" — ":closed" being the Erlang gen_tcp peer-closed reason. No