<@U04S8PLJWMT> We are using the following: Azure ...
# ask-ai
a
@kapa.ai We are using the following: Azure Managed Postgres (version 16.10) with WAL Parameters: max_wal_senders=5 max_wal_size=4096 MB min_wal_size=2048 MB wal_keep_size=400 MB checkpoint_timeout = 10 minutesAirbyte OSS Installation on Azure AKS: Postgres Connector: v3.7.0 Google BigQuery Connector: v3.0.10 UI Platform: 1.5.1 We are using incremental append mode. We are sync'ing Posgtres tables to Google BigQuery every 15 mins using Postgres replication with CDC. The first full refresh works OK. Any subsequent incremental sync fails as follows: Failure in source: Saved offset is before replication slot's confirmed lsn. Please reset the connection, and then increase WAL retention and/or increase sync frequency to prevent this from happening in the future. See [https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#under-cdc-incremental-mode-there-are-still-full-refresh-syncs](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#under-cdc-incremental-mode-there-are-still-full-refresh-syncs) for more details.
k
Based on the knowledge sources, the error you're encountering ("Saved offset is before replication slot's confirmed lsn") is a known issue with the Postgres CDC connector, particularly with versions 3.6.19 and later. Here's what's happening and how to address it: ## Root Cause The issue is related to how the Postgres connector handles LSN (Log Sequence Number) state management. According to [this GitHub issue](https://github.com/airbytehq/airbyte/issues/49802), starting from version 3.6.19, the connector uses a newer version of the PgJDBC driver (42.7.0+) that automatically flushes the LSN even when there are no changes in the publication tables, causing the saved offset to fall behind the confirmed flush LSN. Additionally, [another issue](https://github.com/airbytehq/airbyte/issues/49803) describes how the connector commits an LSN value that's higher than what gets saved in the state during the initial snapshot, leading to subsequent sync failures. ## Solutions ### 1. Downgrade the Connector (Immediate Fix) Multiple users have reported success by downgrading to version 3.6.18, which doesn't have this LSN flushing issue. As mentioned in [this comment](https://github.com/airbytehq/airbyte/issues/55846), "reverting to connector version 3.6.18 resolved this for me." ### 2. Implement Heartbeat Query (Recommended Long-term) Configure a heartbeat query to ensure regular WAL activity. According to the [troubleshooting documentation](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#advanced-wal-disk-consumption-and-heartbeat-action-query): 1. Create a heartbeat table:
Copy code
sql CREATE TABLE airbyte_heartbeat (       id SERIAL PRIMARY KEY,       timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp,       text TEXT   );
2. Add it to your publication:
Copy code
sql ALTER PUBLICATION <publicationName> ADD TABLE airbyte_heartbeat;
3. Configure the "Debezium heartbeat query" in your Postgres source connector:
Copy code
sql INSERT INTO airbyte_heartbeat (text) VALUES ('heartbeat')
This solution has been confirmed to work by users experiencing similar issues, as noted in [this GitHub issue](https://github.com/airbytehq/airbyte/issues/46571). ### 3. Adjust WAL Settings While you already have
wal_keep_size=400 MB
, you might need to increase it further or set
max_slot_wal_keep_size
to ensure WAL files aren't purged before Airbyte can process them. Note: This is a known bug affecting versions 3.6.19 and later, and [users have reported](https://github.com/airbytehq/airbyte/issues/55846) that it blocks production upgrades. The heartbeat solution or downgrading to 3.6.18 are currently the most reliable workarounds.