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(postgres): stop retrying a pooler username the pooler doesn't recognize (#103249)

Tom Owersdf331b19cd00
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py
index 421e7687873f..1307cf233c3c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py
@@ -659,6 +659,17 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
"dashboard for this branch's connection settings, then re-enable the sync."
),
"FATAL: no such database": None,
+ # A connection pooler (e.g. PgBouncer) rejects the connection because the configured
+ # username isn't in its own user list — distinct from Postgres's own
+ # "password authentication failed for user", which means the username exists but the
+ # password is wrong. Deterministic until the customer fixes the pooler username, so
+ # retrying just re-hits it. Match without "FATAL:" since the driver pads the severity
+ # with a variable number of spaces.
+ "no such user": (
+ "Your database connection pooler rejected the connection because it doesn't "
+ 'recognize the configured username ("no such user"). Check the username for this '
+ "source against your pooler's configuration, then re-enable the sync."
+ ),
# A relation or column the sync reads was dropped or renamed on the source, so the
# streaming query fails with SQLSTATE 42P01 ("relation ... does not exist") or 42703
# ("column ... does not exist"). The stored schema/query is fixed until the customer
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 48beabfb949a..2276f376b16f 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
@@ -432,6 +432,10 @@ class TestPostgresSourceNonRetryableErrors:
'could not translate host name "bad-hostname.example.com" to address: Name or service not known',
'FATAL: password authentication failed for user "myuser"',
'FATAL: no such database "nonexistent_db"',
+ # A connection pooler (e.g. PgBouncer) rejects a username it doesn't recognize.
+ # Distinct from "password authentication failed for user", which means the username
+ # exists but the password is wrong.
+ 'connection failed: connection to server at "10.0.0.1", port 6543 failed: FATAL: no such user',
"Name or service not known",
"OperationalError: [Errno -5] No address associated with hostname",
"BaseSSHTunnelForwarderError: Could not establish session to SSH gateway",