Re: How to prevent master server crash if hot standby stops - Mailing list pgsql-general

From Laurenz Albe
Subject Re: How to prevent master server crash if hot standby stops
Date
Msg-id f2d2499b1d8dd8d585e046d26b1dbd4903c2ea00.camel@cybertec.at
Whole thread Raw
In response to Re: How to prevent master server crash if hot standby stops  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: How to prevent master server crash if hot standby stops
List 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




pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: what happens when you issue ALTER SERVER in a hot environment?
Next
From: "Andrus"
Date:
Subject: Re: How to prevent master server crash if hot standby stops