We have a recurring human error problem where, upon doing a base copy to a new slave, we accidentally leave the master’s physical replication slots in place, forgetting to drop them from the slave config.
After a while, transaction logs pile up on the slave — since no slaves are consuming them — and blow it out. This then causes the slave to stop downloading transaction logs from the master, causing them to accumulate due to its own replication slots.
I understand the ultimate solution to this is to mind one’s replication slots and monitor disk usage fastidiously, but is there a config parameter for the maximum overall amount of transaction logs that can be kept accumulated on the master, irrespectively of physical replication slots commitments?
Sent from mobile, with due apologies for brevity and errors.
Re: Physical replication slots and xlog space exhaust
On Mon, Apr 29, 2019 at 12:30:01PM +0200, Juan José Santamaría Flecha wrote:
> > We I understand the ultimate solution to this is to mind one’s replication
> > slots and monitor disk usage fastidiously, but is there a config parameter
> > for the maximum overall amount of transaction logs that can be kept
> > accumulated on the master, irrespectively of physical replication slots
> > commitments?
> Doing that would break the desired functionality of replication slots.
> There is a caution note about this behaviour in the documentation .
> Using the pg_replication_slots view you can check which slot is active or
> if there is a good candidate for dropping.
> Or you can take a more traditional approach using the wal_keep_segments
> parameter instead of slots.
While these are physical rather than logical replication slots, you seem
to be correct:
"In lieu of using replication slots, it is possible to prevent the
removal of old WAL segments using wal_keep_segments, or by storing the
segments in an archive using archive_command. However, these methods
often result in retaining more WAL segments than required, whereas
replication slots retain only the number of segments known to be needed.
An advantage of these methods is that they bound the space requirement
for pg_wal; there is currently no way to do this using replication
I suppose, as usual, I would have been wise to simply RTFM. :-)
Thank you for your feedback!
Alex Balashov | Principal | Evariste Systems LLC