Re: Wrong comment for ReplicationSlotCreate

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Daniil Davydov <3danissimo(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Wrong comment for ReplicationSlotCreate
Date: 2025-12-30 09:18:10
Message-ID: 00DB978B-828D-44FE-8A0B-1643CE03878E@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Dec 29, 2025, at 21:39, Daniil Davydov <3danissimo(at)gmail(dot)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 after commit 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 missing PREPARE.

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/

In response to

Responses

Browse pgsql-hackers by date

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