Re: How to prevent master server crash if hot standby stops

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to prevent master server crash if hot standby stops
Date: 2020-04-07 07:12:25
Message-ID: f2d2499b1d8dd8d585e046d26b1dbd4903c2ea00.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2020-04-07 at 00:50 +0300, Andrus wrote:
> > If you prefer replication to fail silently, don't use replication
> > slots. Use "wal_keep_segments" instead.
>
> I desided to give 1 GB to wal. So I added
>
> wal_keep_segments=60
>
> After some time Postgres created 80 files with total size 1.3GB.
>
> How to fix this so that no more than 1 GB of disk space is used ?
> How to get information how may wal files are yet not processed by slave ?
> How to delete processed wal files so that 1 GB of disk space can used for some other purposes ?

"wal_keep_segments" is the number of old WAL segments the server keeps around
for the standby. But there are also some segments that are created for future
use (the minimum is governed by "min_wal_size").

All these limits are not hard limits, the server will try to keep them
more or less. Consider that WAL segments are created as needed, but only
removed during checkpoints.

So, about your first question, you cannot.
Always make sure that there is more disk space available.

About your second question, you also cannot do that.
The primary server has no idea which standby server needs which WAL information.
All you can tell is where the currently connected standby servers are:

SELECT pg_walfile_name(flush_lsn) FROM pg_stat_replication;

About your third question, you *never* manually mess with the files in pg_wal.
The server does that.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nicola Contu 2020-04-07 08:58:19 Re: EINTR while resizing dsm segment.
Previous Message Laurenz Albe 2020-04-07 06:59:34 Re: what happens when you issue ALTER SERVER in a hot environment?