简体   繁体   中英

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

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

In my case I had to do reinit the replica in maintenance mode using below commands and it fixed the issue. This error was due to lag between leader and replica.

patronictl list

patronictl pause

patronictl reinit patroni

choose Replica pod

patronictl resume

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM