Re: Wrong comment for ReplicationSlotCreate - Mailing list pgsql-hackers

From Chao Li
Subject Re: Wrong comment for ReplicationSlotCreate
Date
Msg-id 00DB978B-828D-44FE-8A0B-1643CE03878E@gmail.com
Whole thread Raw
In response to Wrong comment for ReplicationSlotCreate  (Daniil Davydov <3danissimo@gmail.com>)
Responses Re: Wrong comment for ReplicationSlotCreate
List pgsql-hackers

> On Dec 29, 2025, at 21:39, Daniil Davydov <3danissimo@gmail.com> wrote:
>
> Hi,
>
> I noticed that the comment for ReplicationSlotCreate function contains this
> description for the "two_phase" option :
>
> * two_phase: Allows decoding of prepared transactions. We allow this option
> *     to be enabled only at the slot creation time. If we allow this option
> *     to be changed during decoding then it is quite possible that we skip
> *     prepare first time because this option was not enabled. Now next time
> *     during getting changes, if the two_phase option is enabled it can skip
> *     prepare because by that time start decoding point has been moved. So the
> *     user will only get commit prepared.
>
> But commit [1] introduced the ability to alter the "two_phase" option for the
> replication slot. Thus, I guess that the comment mentioned above is
> outdated and we should change it.
>
> [1] 1462aad2e4474ab61174f8ab00992cd3d6d57c7b
>
> --
> Best regards,
> Daniil Davydov
> <0001-Fix-comment-for-ReplicationSlotCreate.patch>

The old comment claimed “We allow this option to be enabled only at the slot creation time” that is no longer true
aftercommit 1462aad2e4474ab61174f8ab00992cd3d6d57c7b, so yes, the old comment need updating. 

But I think the updated version is too simple. It loses the information that enabling two_phase later can result in
missingPREPARE. 

So, I would suggest something like:
```
* two_phase: If enabled, allows decoding of prepared transactions.
*     Note that enabling this option after decoding has already advanced
*     may result in missing PREPARE records for transactions that were
*     prepared before the option was enabled.

```

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Refactor to eliminate cast-away-const in pg_dump object sort comparator
Next
From: Thomas Munro
Date:
Subject: Re: Compiler warning on Debian 12, PostgreSQL 16 Beta3