This solution is specifically designed for low-traffic or idle databases. Active databases don’t need this feature as their WAL naturally resets with regular data changes.
-- Create the heartbeat tableCREATE TABLE test_heartbeat_table (id text PRIMARY KEY, ts timestamp);-- Grant necessary permissionsGRANT UPDATE ON TABLE test_heartbeat_table TO artie_transfer;-- Insert initial recordINSERT INTO test_heartbeat_table (id, ts) VALUES (1, NOW());
Enable heartbeats in your pipeline’s advanced settings.
If you’re still experiencing WAL growth after enabling heartbeats, check these common issues:
1
Table Existence
Verify test_heartbeat_table exists in your database
2
Publication Configuration
-- Check if the table is included in your publication-- For Artie pipelines, the publication name should default-- to `dbz_publication` (unless changed under Pipeline advanced settings)SELECT pubname, tablenameFROM pg_publication_tablesWHERE tablename = 'test_heartbeat_table';
3
Permission Issues
Confirm the service account has proper write permissions
4
Long-Running Queries
-- Check for queries that might block replicationSELECT pid, now() - pg_stat_activity.query_start AS duration, query, stateFROM pg_stat_activityWHERE (now() - pg_stat_activity.query_start) > interval '1 minute';
To further protect your RDS instance, implement these measures:
Monitoring
Set up alerts for free_storage_space
Monitor WAL growth rates
Database Configuration
Set appropriate statement_timeout
Configure max_slot_wal_keep_size (default is -1 for unlimited)