Re: Propose: Adding a '--enable-failover' option to 'pg_createsubscriber' - Mailing list pgsql-hackers

From Chao Li
Subject Re: Propose: Adding a '--enable-failover' option to 'pg_createsubscriber'
Date
Msg-id 1DDFD1B2-7ED6-47B4-A2F4-A04007FF66B9@gmail.com
Whole thread Raw
In response to Propose: Adding a '--enable-failover' option to 'pg_createsubscriber'  (Ioseph Kim <pgsql-kr@postgresql.kr>)
Responses Re: Propose: Adding a '--enable-failover' option to 'pg_createsubscriber'
List pgsql-hackers
> On Dec 10, 2025, at 17:03, Ioseph Kim <pgsql-kr@postgresql.kr> wrote:
>
> Hi
>
> A failover option has been added to the CREATE SUBSCRITION command, but this functionality isn't easily accessible
usingthe pg_createsubscriber tool. 
>
> Subscriptions created using pg_createsubscriber must be configured for failover via an alter operation.
>
> To address this issue, we've added a simple --enable-failover option to the pg_createsubscriber tool.
>
> This patch is simple. It doesn't handle exceptions or provide any TAP test code.
>
> Please review this and we hope the development team will refine it further.
>
> ioseph
> <0001-Adding-a-enable-failover-option-to-pg_createsubscrib.patch>

Hi, Ioseph,

Thanks for the patch. I consider adding the “(failover=true)” option is useful. A few small comments:

1
```
+      <para>
+       Enables <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>
+       commit for the subscription.
+       The default is <literal>false</literal>.
+      </para>
```

This doc change is confusing. What is “failover commit”? I guess you meant “failover option”?

I’d suggest a phrase like:

“Enables the subscription’s failover option, allowing its logical replication slot to be used after failover.”

2
```
+    printf(_("      --enable-failover           enable failover\n"));
```

If we look at the existing “—enable-two-phase” help text, we consider this help text is too simple. I’d suggest: enable
syncingreplication slots associated with the subscription. 

3
```
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -49,6 +49,7 @@ struct CreateSubscriberOptions
     int            recovery_timeout;    /* stop recovery after this time */
     bool        all_dbs;        /* all option */
     SimpleStringList objecttypes_to_clean;    /* list of object types to cleanup */
+    bool       failover;        /* enable failover option of subscription */
 };

 /* per-database publication/subscription info */
@@ -73,6 +74,7 @@ struct LogicalRepInfos
 {
     struct LogicalRepInfo *dbinfo;
     bool        two_phase;        /* enable-two-phase option */
+    bool        failover;        /* enable failover option of logical replication slot */
     bits32        objecttypes_to_clean;    /* flags indicating which object types
                                          * to clean up on subscriber */
 };
```

Add comments for “failover” in the two structures are inconsistent. The latter one is incorrect, the option is for
“createsubscription” command but for a slot. 

4 You need to run pgindent as I saw some format problems.

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







pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Consistently use palloc_object() and palloc_array()
Next
From: Melanie Plageman
Date:
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)