Thread: pg_rewind and replication slots

pg_rewind and replication slots

From
Laurenz Albe
Date:
When a primary with replication slots gets reset with pg_rewind,
it keeps the replication slots.

This does no harm per se, but when it gets promoted again,
the replication slots are still there and are in the way.
Won't they also hold back the xmin horizon?

I think that pg_rewind should delete all replication slots.

Yours,
Laurenz Albe


Re: pg_rewind and replication slots

From
Michael Paquier
Date:
On Tue, Jan 23, 2018 at 08:49:53PM +0100, Laurenz Albe wrote:
> When a primary with replication slots gets reset with pg_rewind,
> it keeps the replication slots.
>
> This does no harm per se, but when it gets promoted again,
> the replication slots are still there and are in the way.
> Won't they also hold back the xmin horizon?
>
> I think that pg_rewind should delete all replication slots.

Definitely agreed, but replications slots are not the only thing to
worry about. There has been a recent discussion on the matter:
https://www.postgresql.org/message-id/20180122201258.GT2416@tamriel.snowman.net

And the conclusion leads to the fact that we want the list of
directories and files that should be excluded from a base backup to
extracted into a header that pg_rewind could use for its own purpose as
it shares a lot in its logic with basebackup.c, and because using a
logic based on an exclusion list is more portable in the long run.

(I do remove pg_replslot's contents after running pg_rewind in my own
failover scripts by the way.)
--
Michael

Attachment