: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): stop retrying a proxy plan-limit restriction (#83503)
Tom Owers21d8679d94aa
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.pyindex 96c9e5309219..1f30f7262715 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@@ -644,6 +644,17 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa"connect until the database is available again. Upgrade your provider's plan or wait ""for the quota to reset, then re-enable the sync."),+ # A database proxy (observed on Prisma Accelerate) refuses the connection because the+ # account hit a plan limit, reporting "Your account has restrictions: planLimitReached".+ # The restriction is account-level state only the customer can lift (upgrade the plan or+ # contact the provider), so every retry re-hits the same refusal. Match the stable+ # camelCase reason code, which carries no host or account detail.+ "planLimitReached": (+ "Your database provider has restricted the account because a plan limit was reached "+ '("planLimitReached"), so PostHog can\'t connect. This usually comes from a database '+ "proxy such as Prisma. Upgrade the plan or contact your provider to lift the "+ "restriction, then re-enable the sync."+ ),# The provider has put the cluster into read-only mode, so it rejects our read (the# server-side cursor runs its SELECT inside a read/write transaction). PlanetScale's# pg_readonly reports "invalid statement because cluster is read-only"; the cluster onlydiff --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.pyindex 4ff4c826fcf0..509ca681d763 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@@ -422,6 +422,10 @@ class TestPostgresSourceNonRetryableErrors:# customer RLS policy, view, or pooler. Permanent until the customer changes it — must not# keep retrying. Parameter name is invented, not a real customer value.'unrecognized configuration parameter "app.current_tenant"',+ # A database proxy (e.g. Prisma Accelerate) refuses the connection because the account+ # hit a plan limit. Account-level state only the customer can lift, so retrying re-hits+ # the same refusal — must not keep retrying. Host/port are invented, not a real value.+ 'connection failed: connection to server at "db.example.com", port 5432 failed: Your account has restrictions: planLimitReached. Please contact your provider to resolve account restrictions.',],)def test_permanent_connection_errors_are_non_retryable(self, source, error_msg):@@ -458,6 +462,19 @@ class TestPostgresSourceNonRetryableErrors:assert matches[0] is not None, "connect timeout must surface an actionable message, not raw driver text"assert "firewall" in matches[0].lower()+ def test_plan_limit_restriction_surfaces_actionable_message(self, source):+ # A proxy plan-limit refusal must stop retrying and explain how to lift the restriction,+ # rather than storing the raw provider text. Mirror the finalizer's first-match selection.+ error_msg = "Your account has restrictions: planLimitReached. Please contact your provider to resolve account restrictions."+ matches = [+ friendly+ for pattern, friendly in source.get_non_retryable_errors().items()+ if error_message_matches(error_msg, [pattern])+ ]+ assert matches, "plan-limit restriction must be classified non-retryable"+ assert matches[0] is not None, "plan-limit restriction must surface an actionable message, not raw driver text"+ assert "plan" in matches[0].lower()+@pytest.mark.parametrize("error_msg",[