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): stop reporting a self-recovering hot-standby conflict as an exception (#94812)

Tom Owerscc481aeed225
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.py
index f83e79ce214a..e83e41b2dc83 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
@@ -968,11 +968,21 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
# subset) keeps this in sync as new transient classes are added there — a substring added
# to one of those tuples without a matching update here would otherwise keep reporting a
# self-recovering failure to error tracking on every occurrence.
+ #
+ # "conflict with recovery" is the same class again: `get_rows` only applies its in-process
+ # recovery-conflict retry (chunk-shrinking offset/keyset fallback) once it has classified the
+ # connection as a read replica. That classification runs on a setup connection, separate from
+ # the one that serves the read, so a pooled or multi-node reader endpoint can route the two to
+ # different backends and still hit a genuine hot-standby conflict on the read connection while
+ # `using_read_replica` is False. The single-conflict message reaching here (as opposed to the
+ # "kept canceling reads..."/"no key that can resume..." messages above, which are the
+ # exhausted-retry abort and stay non-retryable) is the same self-recovering condition.
return {
*_CONNECTION_DROPPED_ERROR_SUBSTRINGS,
*_POOLER_CONNECTION_DROPPED_ERROR_SUBSTRINGS,
*_SERVER_STARTING_UP_ERROR_SUBSTRINGS,
*_CONNECTION_LIMIT_ERROR_SUBSTRINGS,
+ "conflict with recovery",
}
def reconcile_schema_metadata(
diff --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.py
index 89d59773da54..5b06a90a6d07 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
@@ -562,6 +562,13 @@ class TestPostgresSourceNonRetryableErrors:
[
'OperationalError: connection failed: connection to server at "db.example.com", port 5432 failed: server closed the connection unexpectedly',
'OperationalError: connection failed: connection to server at "db.example.com", port 5432 failed: SSL connection has been closed unexpectedly',
+ # A single hot-standby recovery conflict on a connection `get_rows` didn't classify as a
+ # read replica (e.g. a pooled/multi-node reader endpoint that routed the probe and the
+ # read to different backends), so its in-process offset/keyset fallback never ran and the
+ # raw driver message reaches here instead. It's the same self-recovering condition the
+ # in-process fallback already retries elsewhere, unlike the "kept canceling reads..."/"no
+ # key that can resume..." exhausted-retry aborts below, which stay non-retryable.
+ "canceling statement due to conflict with recovery\nDETAIL: User query might have needed to see row versions that must be removed.",
],
)
def test_exhausted_connection_drops_are_classified_retryable(self, source, error_msg):