Hi <@U04S8PLJWMT>, how can I fix theses issues on ...
# replication-ask-ai
s
Hi @kapa.ai, how can I fix theses issues on a postgres DB? org.postgresql.util.PSQLException: ERROR: can no longer get changes from replication slot "airbyte_slot" Detail: This slot has been invalidated because it was conflicting with recovery.
k
Thinking completed This error indicates that PostgreSQL has invalidated your logical replication slot because it conflicted with recovery on a standby server (or due to resource/WAL constraints). Once a replication slot enters an invalidated or
lost
state, the Postgres connector cannot automatically recover from it within the sync [Github Issue (closed): [source-postgres] Invalid CDC Position Behavior not working; feat(source-postgres): remove non-functional invalid_cdc_cursor_position_behavior option]. To fix this issue and prevent it from recurring, follow these steps: Step 1: Drop and Recreate the Replication Slot An invalidated replication slot cannot be resumed. You must manually drop and recreate the slot on your database [feat(source-postgres): remove non-functional invalid_cdc_cursor_position_behavior option]: 1. In PostgreSQL, drop the broken slot:SELECT pg_drop_replication_slot('airbyte_slot'); 2. Recreate the logical replication slot:SELECT pg_create_logical_replication_slot('airbyte_slot', 'pgoutput'); Step 2: Reset the Airbyte Connection Because the replication slot has been recreated and previous LSN offsets are lost: 1. In the Airbyte UI, go to your connection. 2. Trigger a Reset on the connection/streams to clear the existing state [Github Issue (closed): [source-postgres] Invalid CDC Position Behavior not working]. 3. Run a sync to trigger a fresh initial snapshot/sync. Step 3: Prevent Conflicts with Recovery If Airbyte is reading from a Hot Standby (read replica), queries and replication slots conflict with changes being replayed from the primary. To prevent the slot from being invalidated again: • Enable
hot_standby_feedback
(Recommended):
Set
hot_standby_feedback = true
on the standby server [Documentation Integrations > Sources > Postgres > Troubleshooting Postgres Sources>]. This informs the primary server about what the replica needs and prevents row versions/WAL needed by queries from being prematurely cleaned up. • Sync from the primary: If possible, point the Airbyte source to the primary PostgreSQL server rather than the hot standby [Documentation Integrations > Sources > Postgres > Troubleshooting Postgres Sources>]. • Tune standby delay parameters: You can increase
max_standby_archive_delay
and
max_standby_streaming_delay
to give queries on the replica more time before being canceled [Documentation Integrations > Sources > Postgres > Troubleshooting Postgres Sources>]. • Tune WAL retention & sync frequency: Ensure syncs run frequently enough, and configure sufficient WAL retention (such as tuning
wal_keep_size
on PG 13+) so the slot does not fall behind and get dropped [Github Issue (closed): [source-postgres] Invalid CDC Position Behavior not working; Documentation Integrations > Sources > Postgres > Troubleshooting Postgres Sources>]. 👍 0 button 👎 0 button ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.