Re: Physical replication slot advance is not persistent
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>, Dimitri Fontaine <dim@tapoueh.org>
Cc: Alexey Kondratov <a.kondratov@postgrespro.ru>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, pgsql-hackers@postgresql.org, simon@2ndquadrant.com
Date: 2020-06-09T17:19:04Z
Lists: pgsql-hackers
Hi,
On 2020-01-28 17:01:14 +0900, Michael Paquier wrote:
> So attached is an updated patch which addresses the problem just by
> marking a physical slot as dirty if any advancing is done. Some
> documentation is added about the fact that an advance is persistent
> only at the follow-up checkpoint. And the tests are fixed to not use
> a fake LSN but instead advance to the latest LSN position produced.
>
> - /* Update the on disk state when lsn was updated. */
> - if (XLogRecPtrIsInvalid(endlsn))
> - {
> - ReplicationSlotMarkDirty();
> - ReplicationSlotsComputeRequiredXmin(false);
> - ReplicationSlotsComputeRequiredLSN();
> - ReplicationSlotSave();
> - }
> -
I am quite confused by the wholesale removal of these lines. That wasn't
in previous versions of the patch. As far as I can tell not calling
ReplicationSlotsComputeRequiredLSN() for the physical slot leads to the
global minimum LSN never beeing advanced, and thus WAL reserved by the
slot not being removable. Only if there's some independent call to
ReplicationSlotsComputeRequiredLSN() XLogSetReplicationSlotMinimumLSN()
will be called, allowing for slots to advance.
I realize this stuff has been broken since the introduction in
9c7d06d6068 (due to the above being if (XLogRecPtrIsInvalid()) rather
than if (!XLogRecPtrIsInvalid()) , but this seems to make it even worse?
I find it really depressing how much obviously untested stuff gets
added in this area.
Greetings,
Andres Freund
Commits
-
Fix oldest xmin and LSN computation across repslots after advancing
- 1657e14b50d2 11.9 landed
- 16f43122d46f 12.4 landed
- 43e70addf5a6 13.0 landed
- b48df818dcbd 14.0 landed
-
Fix slot data persistency when advancing physical replication slots
- 374464c3e96f 11.7 landed
- 3228512b7b2b 12.2 landed
- b0afdcad21fd 13.0 landed