BUG #15323: wal_keep_segments must be >= 1 for WAL archiving +streaming to work - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15323: wal_keep_segments must be >= 1 for WAL archiving +streaming to work
Date
Msg-id 153417102094.10285.2862376186524898868@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #15323: wal_keep_segments must be >= 1 for WAL archiving +streaming to work  (Andres Freund <andres@anarazel.de>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15323
Logged by:          Phil Endecott
Email address:      spam_from_pgsql_lists@chezphil.org
PostgreSQL version: 9.6.10
Operating system:   Debian Stretch
Description:

I have set up a replication system that uses a combination of WAL segment
archiving and streaming.
If the slave goes down for a period, when it restarts it will initially
fetch WAL segment files from the archive using restore_command.  After
fetching the last of these it will start streaming directly from the
master.
It seems that the WAL segment files may have a small empty space at the end
due presumably to the size of the records.  In my case, the last archived
WAL segment ended at offset 0xFFF088.  The slave therefore tried to start
streaming at that position.  But the master had already archived that
segment and recycled it, because I had not set wal_keep_segments and it
defaults to 0.  Streaming therefore failed to start.
It seems to me that wal_keep_segments must always be >= 1 for the
combination of WAL archiving and streaming to work.
If this understanding is correct, the fix could be some combination of:
(a) Make the default for wal_keep_segments 1.
(b) Make the default for wal_keep_segments 1 if archiving is enabled.
(c) Make the WAL restore process skip over this end-of-segment gap and start
streaming at the start of the master's current segment.
(d) Document that wal_keep_segments must be >= 1 in this case.  (The current
docs in section 2.26.5 say that "if you set up a WAL archive that's
accessible from the standby, these solutions [meaning wal_keep_segments and
replication slots] are not required".)

See also:
https://www.postgresql.org/message-id/flat/1534100972118%40dmwebmail.dmwebmail.chezphil.org

Thanks, Phil.


pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BUG #15321: XMLTABLE leaks memory like crazy
Next
From: Andres Freund
Date:
Subject: Re: BUG #15323: wal_keep_segments must be >= 1 for WAL archiving +streaming to work