Mohammad Atif
12/31/2025, 7:51 AMkapa.ai
12/31/2025, 7:51 AMwal_keep_size flag specifically for Cloud SQL for PostgreSQL. However, the documentation and community discussions suggest several strategies to resolve this "Saved offset is before replication slot's confirmed LSN" error when you cannot modify that specific flag. ### Understanding the Error This error occurs when the Write-Ahead Logs (WAL) required for an incremental sync have been removed by Postgres before Airbyte could process them [[Troubleshooting Postgres Sources](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#troubleshooting)]. This is common in environments with low transaction volumes where the confirmed_flush_lsn does not advance, or in high-volume environments where logs are purged too quickly [[Resolving sync failures](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#advanced-wal-disk-consumption-and-heartbeat-action-query)]. ### Recommended Solutions #### 1. Implement a Heartbeat Table (Recommended for Cloud SQL) If your database has low traffic, the replication slot might not advance, leading to WAL retention issues. You can manually force the LSN to advance by creating a heartbeat table that Airbyte writes to periodically: 1. Create a heartbeat table in your Postgres database: sql CREATE TABLE airbyte_heartbeat ( id SERIAL PRIMARY KEY, timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp, text TEXT ); 2. Add the table to your publication: sql ALTER PUBLICATION <your_publication_name> ADD TABLE airbyte_heartbeat; 3. Configure the Heartbeat Query in the Airbyte Source settings under the "Debezium heartbeat query" property: sql INSERT INTO airbyte_heartbeat (text) VALUES ('heartbeat') Airbyte will execute this query periodically to ensure the WAL advances [[Resolving sync failures](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#advanced-wal-disk-consumption-and-heartbeat-action-query)]. #### 2. Use pg_cron for Automated Heartbeats For a more automated approach in Cloud SQL, you can use the pg_cron extension to insert values into a heartbeat table every minute. This ensures the replication slot is cleared even when there are no changes in your primary data tables [[Troubleshooting Postgres Sources](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#wal-heartbeat-table)]. * Enable the cloudsql.enable_pg_cron flag in your Cloud SQL instance settings. * Add pg_cron to shared_preload_libraries [[Troubleshooting Postgres Sources](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#add-the-pg_cron-extension)]. #### 3. Increase Sync Frequency If the WAL is being purged because too much time passes between syncs, increasing the frequency of your Airbyte connection (e.g., from every 24 hours to every 1 hour) can prevent the logs from being recycled before the next sync starts [[Troubleshooting Postgres Sources](https://docs.airbyte.com/integrations/sources/postgres/postgres-troubleshooting#troubleshooting)]. #### 4. Adjust Invalid CDC Position Behavior In your Airbyte connection settings, you can change the Invalid CDC position behavior from Fail sync to Re-sync data. While this will trigger a full refresh when the LSN is lost (which may be expensive for large tables), it prevents the connection from staying in a failed state [[Github Issue (open)](https://github.com/airbytehq/airbyte/issues/55846); [CDC Not Working](https://github.com/airbytehq/airbyte/issues/49802)].