Re: pg_dump writes a subscription's default slot name, which can't be restored

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: pg_dump writes a subscription's default slot name, which can't be restored
Date: 2026-12-04 03:11:06
Message-ID: 1E452A48-82A5-464D-812E-8B72CF6ED9A5@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Dec 4, 2026, at 09:56, Baji Shaik <baji(dot)pgdev(at)gmail(dot)com> wrote:
>
> Hello Zsolt,
>
> On Thu, Dec 3, 2026 at 5:55 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> Thank you so much for review and feedback.
> 1. CREATE SUBSCRIPTION none CONNECTION '...' PUBLICATION p WITH
> (connect = false);
>
> This is a not-so realistic corner case, but for this case restore
> still doesn't work even with the patch.
>
> Right, and it doesn't even fail. v2 rejects "none" as the default slot name too.
> 2.
>
> +WARNING: subscriptions created by regression test cases should have
> names starting with "regress_"
>
> Renamed it to "regress_TestSub", and the reserved name and "none"
> tests now run with client_min_messages = ERROR.
>
> 3.
> Another nitpick: the CREATE SUBSCRIPTION / the user didn't specify any
> slot name. Maybe this could have a detail explaining that? 'The
> subscription name is used as the replication slot name when slot_name
> is not specified' or something like that.
> 4. Should the documentation be also updated to mention this?
>
> Added the DETAIL and updated the slot_name description in
> CREATE SUBSCRIPTION.
> Thanks,
> Baji Shaik
> <v2-0001-Validate-the-default-slot-name-in-CREATE-SUBSCRIP.patch>

I think the initial patch was trying to handle existing invalid slot names, while with Masahiko-san’s suggestion, it switched direction to block future invalid slot names. So, if a database already contains an invalid slot name, such as “MySub”, pg_restore will still fail, and pg_upgrade will still fail.

Maybe we can add a check to “pg_upgrade --check”, so that users can detect the error earlier and fix it before an actual upgrade. But I have no idea how we can improve pg_restore to handle existing invalid slot names.

WRT v2, I don’t think we should block “none”, because doing so will lead to inconsistent behaviors:
```
evantest=# CREATE SUBSCRIPTION none CONNECTION 'dbname=postgres' PUBLICATION p WITH (connect = false);
ERROR: replication slot name "none" cannot be used
DETAIL: The subscription name is used as the replication slot name when slot_name is not specified.
HINT: Specify a different slot_name for the subscription.
evantest=#
evantest=#
evantest=# CREATE SUBSCRIPTION none CONNECTION 'dbname=postgres' PUBLICATION p WITH (connect = false, slot_name='none');
WARNING: subscription was created, but is not connected
HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and alter the subscription to refresh publications.
CREATE SUBSCRIPTION
```

With v2, the first CREATE SUBSCRIPTION fails, but the second still succeeds with NULL stored in subslotname, which seems inconsistent. Normally, when the subscription name is a valid slot name, explicitly specifying the subscription name as slot_name should behave the same way as omitting slot_name. IMO, the first should also succeed and behave the same way as the second.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-12-04 03:16:51 Re: pg_receivewal doesn't truncate compressed WAL files on restart
Previous Message John Naylor 2026-12-04 03:09:00 Re: memory leak in bounded sorts