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(data-warehouse): set postgres statement_timeout via client cursor (#60694)

Tom Owersbe75a4e851af
diff --git a/posthog/temporal/data_imports/sources/postgres/postgres.py b/posthog/temporal/data_imports/sources/postgres/postgres.py
index 3d4f1e5cadab..71c2d3e9ec2d 100644
--- a/posthog/temporal/data_imports/sources/postgres/postgres.py
+++ b/posthog/temporal/data_imports/sources/postgres/postgres.py
@@ -1860,7 +1860,9 @@ def postgres_source(
# wide/partitioned scans the source's default (often 30-60s)
# kills the fetch before rows come back.
try:
- with connection.cursor() as setup_cursor:
+ # Use psycopg.Cursor directly to bypass cursor_factory (which may be
+ # ServerCursor and requires a `name` arg, breaking an unnamed cursor()).
+ with psycopg.Cursor(connection) as setup_cursor:
setup_cursor.execute(
sql.SQL("SET statement_timeout = {timeout}").format(
timeout=sql.Literal(SYNC_STATEMENT_TIMEOUT_MS)