Subject: Re: [HACKERS] logical decoding of two-phase transactions

From: Masahiko Sawada <[email-masked]>
Date: Tue, 4 Jan 2022 12:30:06 +0900

Hi,

On Mon, Aug 9, 2021 at 12:00 PM Amit Kapila <[email-masked]> wrote:
>
> On Wed, Aug 4, 2021 at 4:14 PM Amit Kapila <[email-masked]> wrote:
> >
> > I have pushed this last patch in the series.
> >
>
> I have closed this CF entry. Thanks to everyone involved in this work!
>

I have a questoin about two_phase column of pg_replication_slots view:
with this feature, pg_replication_slots has a new column two_phase:

             View "pg_catalog.pg_replication_slots"
       Column        |  Type   | Collation | Nullable | Default
---------------------+---------+-----------+----------+---------
 slot_name           | name    |           |          |
 plugin              | name    |           |          |
 slot_type           | text    |           |          |
 datoid              | oid     |           |          |
 database            | name    |           |          |
 temporary           | boolean |           |          |
 active              | boolean |           |          |
 active_pid          | integer |           |          |
 xmin                | xid     |           |          |
 catalog_xmin        | xid     |           |          |
 restart_lsn         | pg_lsn  |           |          |
 confirmed_flush_lsn | pg_lsn  |           |          |
 wal_status          | text    |           |          |
 safe_wal_size       | bigint  |           |          |
 two_phase           | boolean |           |          |

According to the doc, the two_phase field has:

True if the slot is enabled for decoding prepared transactions. Always
false for physical slots.

It's unnatural a bit to me that replication slots have such a property
since the replication slots have been used to protect WAL and tuples
that are required for logical decoding, physical replication, and
backup, etc from removal. Also, it seems that even if a replication
slot is created with two_phase = off, it's overwritten to on if the
plugin enables two-phase option. Is there any reason why we can turn
on and off this value on the replication slot side and is there any
use case where the replication slot’s two_phase is false and the
plugin’s two-phase option is on and vice versa? I think that we can
have replication slots always have two_phase_at value and remove the
two_phase field from the view.

Regards,

-- 
Masahiko Sawada
EDB:  https://www.enterprisedb.com/