Physical replication slots and xlog space exhaust

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Physical replication slots and xlog space exhaust

Alex Balashov
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?

Thanks!


Sent from mobile, with due apologies for brevity and errors.

Reply | Threaded
Open this post in threaded view
|

Re: Physical replication slots and xlog space exhaust

Alex Balashov
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 [1].
>
> 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.

Hi,

While these are physical rather than logical replication slots, you seem
to be correct:

https://www.postgresql.org/docs/current/warm-standby.html#STREAMING-REPLICATION-SLOTS

   "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
    slots."

I suppose, as usual, I would have been wise to simply RTFM. :-)

Thank you for your feedback!

-- Alex

--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/