[HACKERS] Replication slot xmin is not reset if HS feedback is turned off whilestandby is shut down - Mailing list pgsql-hackers

From Ants Aasma
Subject [HACKERS] Replication slot xmin is not reset if HS feedback is turned off whilestandby is shut down
Date
Msg-id CA+CSw_v5bhRD7=bV7_Uaya3qTo=LYN6t3R50WDeL25LhZKpCuQ@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] Replication slot xmin is not reset if HS feedback isturned off while standby is shut down  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
I just had a client issue with table bloat that I traced back to a
stale xmin value in a replication slot. xmin value from hot standby
feedback is stored in replication slot and used for vacuum xmin
calculation. If hot standby feedback is turned off while walreceiver
is active then the xmin gets reset by HS feedback message containing
InvalidTransactionId. However, if feedback gets turned off while
standby is shut down this message never gets sent and a stale value
gets left behind in the replication slot holding back vacuum.

The simple fix seems to be to always send out at least one feedback
message on each connect regardless of hot_standby_feedback setting.
Patch attached. Looks like this goes back to version 9.4. It could
conceivably cause issues for replication middleware that does not know
how to handle hot standby feedback messages. Not sure if any exist and
if that is a concern.

A shell script to reproduce the problem is also attached, adjust the
PGPATH variable to your postgres install and run in an empty
directory.

Regards,
Ants Aasma

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] Declarative partitioning - another take
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] Declarative partitioning - another take