Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres Streaming Replication Error: requested WAL segment has already been removed

I have setup streaming replication between a primary and secondary server. I have enabled archiving. In the Postgres log file I am seeing the below error.

< 2017-12-05 03:08:45.374 UTC > WARNING:  archive_mode enabled, yet archive_command is not set
< 2017-12-05 03:08:46.668 UTC > ERROR:  requested WAL segment 0000000100000000000000E3 has already been removed
< 2017-12-05 03:08:51.675 UTC > ERROR:  requested WAL segment 0000000100000000000000E3 has already been removed
< 2017-12-05 03:08:56.682 UTC > ERROR:  requested WAL segment 0000000100000000000000E3 has already been removed

Do we need to enable archive_mode = on for streaming replication? How can I avoid above error?

max_wal_senders = 3
wal_keep_segements = 32
like image 988
varun7447 Avatar asked Oct 21 '25 16:10

varun7447


1 Answers

https://www.postgresql.org/docs/current/static/warm-standby.html

If you use streaming replication without file-based continuous archiving, the server might recycle old WAL segments before the standby has received them. If this occurs, the standby will need to be reinitialized from a new base backup. You can avoid this by setting wal_keep_segments to a value large enough to ensure that WAL segments are not recycled too early, or by configuring a replication slot for the standby. If you set up a WAL archive that's accessible from the standby, these solutions are not required, since the standby can always use the archive to catch up provided it retains enough segments.

emphasis mine.

so either increase wal_keep_segments to big enough (enough for your amount of block changes), or configure archive_command and set up some storage to keep removed wals from master to be available for slave. Or configuring a replication slot for the standby...

like image 124
Vao Tsun Avatar answered Oct 23 '25 08:10

Vao Tsun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!