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(redshift): Raise non-retryable error on quota exceeded (#80361)

Tomás Farías Santanad4728fedf720
diff --git a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
index 30018f7aaf33..200be848c74b 100644
--- a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
@@ -985,6 +985,13 @@ async def insert_into_redshift_activity_from_stage(inputs: RedshiftInsertInputs)
table_fields = [field for field in table_schemas.table_schema if field[0] in columns]
except (psycopg.errors.UndefinedTable, psycopg.errors.InternalError_):
table_fields = list(table_schemas.table_schema)
+ except psycopg.errors.QueryCanceled as e:
+ if "usage limit" in str(e):
+ raise InsufficientSystemResourcesError(
+ "A spending or usage quota was hit and the batch export cannot proceed. "
+ "Consider raising the quota after identifying the one that fired."
+ )
+ raise
primary_key = merge_settings.primary_key if merge_settings.requires_merge is True else None
async with (