: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(warehouse-sources): guide users when CDC setup hits a read-only database (#85078)
Tom Owers52421f433bea
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.pyindex f02e1020e913..2501f5aca55c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/adapter.py@@ -65,6 +65,15 @@ def _slot_setup_error_message(exc: Exception) -> str:"Either grant it replication access, or switch these tables to Incremental sync ""instead of CDC. Incremental needs only SELECT permission.")+ # A read replica or read-only standby rejects the CREATE PUBLICATION that CDC needs.+ if "in a read-only transaction" in message:+ return (+ f"Failed to create replication slot: {exc} "+ "CDC has to create a replication slot and publication, which only a writable primary "+ "database allows. This connection points at a read replica or read-only standby. "+ "Connect to the primary database, or switch these tables to Incremental sync, which "+ "needs only SELECT."+ )return f"Failed to create replication slot: {exc}"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.pyindex 11a1950f4ddf..811bcd74d597 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/tests/test_adapter.py@@ -185,6 +185,11 @@ class TestSlotSetupErrorMessage:error = _slot_setup_error_message(Exception("ERROR: must be superuser or replication role"))assert "Incremental sync" in error+ def test_read_only_transaction_error_points_at_primary(self) -> None:+ error = _slot_setup_error_message(Exception("cannot execute CREATE PUBLICATION in a read-only transaction"))+ assert "primary database" in error+ assert "Incremental sync" in error+def test_non_permission_error_keeps_raw_message_only(self) -> None:error = _slot_setup_error_message(RuntimeError("connection reset"))assert error == "Failed to create replication slot: connection reset"