: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 "(ENOTFOUND) tenant/user not found" as non-retryable (#63699)
Tom Owers371470840ede
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.pyindex 3ff0ab1d0d92..b004fe2ecc7a 100644--- a/posthog/temporal/data_imports/sources/postgres/source.py+++ b/posthog/temporal/data_imports/sources/postgres/source.py@@ -174,6 +174,17 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa"is not permitted to log in": None,"Tenant or user not found connection to server": None,"FATAL: Tenant or user not found": None,+ # Newer Supabase/Supavisor poolers report a missing tenant/user with a different+ # wording than the two lines above ("FATAL: (ENOTFOUND) tenant/user <user> not found").+ # It means the pooler can't resolve the project ref or pooler username — the project is+ # paused/deleted or the credentials are wrong — so it's permanent until the customer+ # fixes their config. Match the stable fragment and exclude the volatile username/host.+ "(ENOTFOUND) tenant/user": (+ "Your database connection pooler couldn't find the tenant or user "+ '("tenant/user not found"). This usually means the database project is paused or '+ "deleted, or the pooler username/host is wrong. Check that your database is active "+ "and the connection details are correct, then re-enable the sync."+ ),"error received from server in SCRAM exchange: Wrong password": None,"could not translate host name": None,"timeout expired connection to server at": None,diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.pyindex 2445a73e4312..33d088cb8787 100644--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py@@ -144,6 +144,10 @@ class TestPostgresSourceNonRetryableErrors:'FATAL: no such database "nonexistent_db"',"Name or service not known","BaseSSHTunnelForwarderError: Could not establish session to SSH gateway",+ # Newer Supabase/Supavisor pooler wording for a missing tenant/user. The older+ # "Tenant or user not found connection to server" / "FATAL: Tenant or user not found"+ # patterns don't substring-match this, so it needs its own key.+ 'connection failed: connection to server at "52.45.94.125", port 6543 failed: FATAL: (ENOTFOUND) tenant/user postgres.hksbxxtlcfeyyalgveif not found',],)def test_permanent_connection_errors_are_non_retryable(self, source, error_msg):@@ -151,6 +155,19 @@ class TestPostgresSourceNonRetryableErrors:is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())assert is_non_retryable, f"Permanent error should be non-retryable: {error_msg}"+ def test_supavisor_enotfound_tenant_user_uses_new_key(self, source):+ # The older tenant/user patterns don't cover the newer "(ENOTFOUND) tenant/user" wording,+ # so confirm it's specifically the new key that recognises this message.+ error_msg = (+ 'connection failed: connection to server at "52.45.94.125", port 6543 failed: '+ "FATAL: (ENOTFOUND) tenant/user postgres.hksbxxtlcfeyyalgveif not found"+ )+ non_retryable = source.get_non_retryable_errors()+ assert "(ENOTFOUND) tenant/user" in non_retryable+ assert "Tenant or user not found connection to server" not in error_msg+ assert "FATAL: Tenant or user not found" not in error_msg+ assert any(pattern in error_msg for pattern in non_retryable.keys())+@pytest.mark.parametrize("error_msg",[