Re: Possible bug in logical replication.
Arseny Sher <a.sher@postgrespro.ru>
From: Arseny Sher <a.sher@postgrespro.ru>
To: Michael Paquier <michael@paquier.xyz>
Cc: Arseny Sher <a.sher@postgrespro.ru>,
Alvaro Herrera <alvherre@2ndquadrant.com>,
Simon Riggs <simon@2ndquadrant.com>,
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>,
Sawada Masahiko <sawada.mshk@gmail.com>,
konstantin knizhnik <k.knizhnik@postgrespro.ru>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Petr Jelinek <petr.jelinek@2ndquadrant.com>
Date: 2018-06-20T07:59:28Z
Lists: pgsql-hackers
Attachments
- lslot_advance_comments.patch (text/x-diff) patch
Michael Paquier <michael@paquier.xyz> writes: > On Mon, Jun 18, 2018 at 09:42:36PM +0900, Michael Paquier wrote: >> On Fri, Jun 15, 2018 at 06:27:56PM +0300, Arseny Sher wrote: >> It seems to me that we still want to have the slot forwarding finish in >> this case even if this is interrupted. Petr, isn't that the intention >> here? > > I have been chewing a bit more on the proposed patch, finishing with the > attached to close the loop. Thoughts? Sorry for being pedantic, but it seems to me worthwhile to mention *why* we need decoding machinery at all -- like I wrote: + * While we could just do LogicalConfirmReceivedLocation updating + * confirmed_flush_lsn, we'd better digest WAL to advance restart_lsn + * (allowing to recycle WAL) and xmin (allowing to vacuum old catalog tuples). Also, > * The slot's restart_lsn is used as start point for reading records, This is clearly seen from the code, I propose to remove this. > * while confirmed_lsn is used as base point for the decoding context. And as I wrote, this doesn't matter as changes are not produced. > * The LSN position to move to is checked by doing a per-record scan and > * logical decoding which makes sure that confirmed_lsn is updated to a > * LSN which allows the future slot consumer to get consistent logical > - * changes. > + * changes. As decoding is done with fast_forward mode, no changes are > + * actually generated. confirmed_lsn is always updated to `moveto` unless we run out of WAL earlier (and unless we try to move slot backwards, which is obviously forbidden) -- consistent changes are practically irrelevant here. Moreover, we can directly set confirmed_lsn and still have consistent changes further as restart_lsn and xmin of the slot are not touched. What we actually do here is trying to advance *restart_lsn and xmin* as far as we can but up to the point which ensures that decoding can assemble a consistent snapshot allowing to fully decode all COMMITs since updated `confirmed_flush_lsn`. All this happens in SnapBuildProcessRunningXacts. > It seems to me that we still want to have the slot forwarding finish in > this case even if this is interrupted. Petr, isn't that the intention > here? Probably, though I am not sure what is the point of this. Ok, I keep this check in the updated (with your comments) patch and CC'ing Petr. -- Arseny Sher Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
Commits
-
Rewrite comments in replication slot advance implementation
- 96bd49437cca 11.0 landed
- 1573995f5599 12.0 landed
-
Fix a couple of bugs with replication slot advancing feature
- f731cfa94c00 11.0 landed
-
Ability to advance replication slots
- 9c7d06d60680 11.0 cited