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): treat exceeded compute-time quota as non-retryable (#64064)

Tom Owersa7b2c4e8d0f9
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.py
index 93a474043680..ac7d7f300786 100644
--- a/posthog/temporal/data_imports/sources/postgres/source.py
+++ b/posthog/temporal/data_imports/sources/postgres/source.py
@@ -274,6 +274,18 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
"the pooler's credentials for the database are wrong. Check that the database is "
"running and reachable from your pooler, then re-enable the sync."
),
+ # Serverless Postgres providers (e.g. Neon) suspend a project's compute once it exhausts
+ # the plan's compute-time quota, and the connection attempt fails at handshake with
+ # "Your account or project has exceeded the compute time quota. Upgrade your plan to
+ # increase limits." The compute stays suspended until the customer upgrades their plan or
+ # the quota resets at the next billing period, so retrying the activity just re-hits the
+ # same wall. Match the stable provider message and exclude the volatile host/IP/port.
+ "exceeded the compute time quota": (
+ "Your database provider has suspended the database because the account or project "
+ 'exceeded its compute-time quota ("exceeded the compute time quota"). PostHog can\'t '
+ "connect until the database is available again. Upgrade your provider's plan or wait "
+ "for the quota to reset, then re-enable the sync."
+ ),
# `offset_chunking` retries a Postgres standby recovery conflict ("canceling statement
# due to conflict with recovery") 30 times in-process with backoff + chunk-size
# reduction before raising this. The conflict comes from the customer's read replica
diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.py
index 5a9e441dba37..6c5d928dfc5d 100644
--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py
+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py
@@ -304,6 +304,27 @@ class TestPostgresSourceNonRetryableErrors:
assert friendly, "TLS ALPN rejection error should surface an actionable message"
assert "host and port" in friendly[0]
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ # Neon suspends compute when the plan's compute-time quota is exhausted; the handshake
+ # fails with this provider message. The host/IP and port are volatile and excluded.
+ 'connection failed: connection to server at "44.198.216.75", port 5432 failed: ERROR: Your account or project has exceeded the compute time quota. Upgrade your plan to increase limits.',
+ "OperationalError: Your account or project has exceeded the compute time quota. Upgrade your plan to increase limits.",
+ ],
+ )
+ def test_exceeded_compute_time_quota_is_non_retryable(self, source, error_msg):
+ non_retryable = source.get_non_retryable_errors()
+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
+ assert is_non_retryable, f"Exceeded compute-time quota error should be non-retryable: {error_msg}"
+
+ def test_exceeded_compute_time_quota_returns_friendly_message(self, source):
+ non_retryable = source.get_non_retryable_errors()
+ error_msg = "Your account or project has exceeded the compute time quota. Upgrade your plan to increase limits."
+ friendly = [reason for pattern, reason in non_retryable.items() if pattern in error_msg and reason]
+ assert friendly, "Exceeded compute-time quota error should surface an actionable message"
+ assert "compute-time quota" in friendly[0]
+
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.