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(temporal): treat EAI_AGAIN DNS failures as transient db errors (#113520)

posthog[bot]984e17cb068d
diff --git a/posthog/temporal/common/db_errors.py b/posthog/temporal/common/db_errors.py
index 5000c7ebee12..2ca259a3c074 100644
--- a/posthog/temporal/common/db_errors.py
+++ b/posthog/temporal/common/db_errors.py
@@ -51,6 +51,11 @@ _TRANSIENT_DB_ERROR_MARKERS = (
# database would. Self-healing: a slot frees the moment another backend connection closes,
# which happens continuously under normal load.
"sorry, too many clients already",
+ # getaddrinfo EAI_AGAIN (errno -3): the resolver could not get an answer now, for example during
+ # a short cluster DNS outage. It clears when DNS comes back, so a retry self-heals. EAI_NONAME
+ # (errno -2, "Name or service not known") and EAI_NODATA (errno -5, "No address associated with
+ # hostname") stay unmatched, because both can mean a host that never resolves.
+ "Temporary failure in name resolution",
)
# SQLSTATE class 57P (operator intervention): the server is shutting down or restarting and
diff --git a/posthog/temporal/common/test_db_errors.py b/posthog/temporal/common/test_db_errors.py
index 41b110dca53e..d89d24d54520 100644
--- a/posthog/temporal/common/test_db_errors.py
+++ b/posthog/temporal/common/test_db_errors.py
@@ -53,6 +53,16 @@ def _raised_from(error: BaseException, cause: BaseException) -> BaseException:
),
(OperationalError("connection failed: FATAL: password authentication failed for user"), False),
(OperationalError("no such database"), False),
+ (OperationalError("[Errno -3] Temporary failure in name resolution"), True),
+ (
+ OperationalError(
+ 'connection failed: could not translate host name "db.example.com" to address: '
+ "Temporary failure in name resolution"
+ ),
+ True,
+ ),
+ (OperationalError("[Errno -2] Name or service not known"), False),
+ (OperationalError("[Errno -5] No address associated with hostname"), False),
# psycopg raises this straight off local state (no new network I/O) when a connection
# already marked dead by an earlier operation is reused — the same dropped-connection
# condition as "server closed the connection unexpectedly", just discovered later.