: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(temporal): treat postgres connection-limit rejections as transient (#113647)
Tom Owersc2a2d29befe3
diff --git a/posthog/temporal/common/db_errors.py b/posthog/temporal/common/db_errors.pyindex bfbfe2f359ac..245be430a86d 100644--- a/posthog/temporal/common/db_errors.py+++ b/posthog/temporal/common/db_errors.py@@ -46,6 +46,11 @@ _TRANSIENT_DB_ERROR_MARKERS = (# instead of on the read/write that first found it dead. close_old_connections() at the top of# the next activity attempt discards the broken connection, so a retry self-heals."the connection is closed",+ # Postgres rejects a new connection once every `max_connections` slot is taken, before+ # authentication runs, so it carries no SQLSTATE the way a rejected password or a missing+ # database would. Self-healing: a slot frees the moment another backend connection closes,+ # which happens continuously under normal load.+ "sorry, too many clients already",)# SQLSTATE class 57P (operator intervention): the server is shutting down or restarting anddiff --git a/posthog/temporal/common/test_db_errors.py b/posthog/temporal/common/test_db_errors.pyindex a1e1585b81b7..41b110dca53e 100644--- a/posthog/temporal/common/test_db_errors.py+++ b/posthog/temporal/common/test_db_errors.py@@ -44,6 +44,13 @@ def _raised_from(error: BaseException, cause: BaseException) -> BaseException:),True,),+ (+ OperationalError(+ 'connection failed: connection to server at "10.0.0.1", port 5432 failed: '+ "FATAL: sorry, too many clients already"+ ),+ True,+ ),(OperationalError("connection failed: FATAL: password authentication failed for user"), False),(OperationalError("no such database"), False),# psycopg raises this straight off local state (no new network I/O) when a connection