This article explains how to mitigate PostgreSQL replication slot stalls and WAL accumulation during CDC-based migrations. By implementing heartbeat tables that periodically update a row, developers can force the replication slot LSN to advance, preventing disk space exhaustion when replicating only a subset of database tables.
Key points
Replication slots track WAL sequence numbers, and if they don't advance due to low activity on specific tables, WAL files accumulate on the disk.
Partial table replication or multi-database clusters can cause specific slots to stall even when the overall database cluster remains active.
Heartbeat tables force periodic write activity, ensuring the replication slot LSN moves forward even when replicated data is idle.
Monitor WAL size and replication slot lag to detect potential disk pressure before it results in service downtime.