Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Date: 2025-10-24 02:40:03
Message-ID: CAHut+PvmCxDJgXXf=phcJihKogq8W=g2t0KT0g2uO8khYCj=5Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Sawada-San.

A couple of review questions/comments for patch v24.

======
src/backend/commands/publicationcmds.c

1.
- if (wal_level != WAL_LEVEL_LOGICAL)
+ if (!IsLogicalDecodingEnabled())
ereport(WARNING,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("\"wal_level\" is insufficient to publish logical changes"),
- errhint("Set \"wal_level\" to \"logical\" before creating subscriptions.")));
+ errmsg("logical decoding must be enabled to publish logical changes"),
+ errhint("Before creating subscriptions, set \"wal_level\" >=
\"logical\" or create a logical replication slot when \"wal_level\" =
\"replica\".")));

The hint still says "or create a logical replication slot...", which I
thought I showed to be redundant info. It makes the user think that
they might have to do something when, AFAIK, they don't.

My suggestion is just to tweak the current master hin, like:
errhint("Set \"wal_level\" >= \"replica\" before creating subscriptions.")));

======
src/backend/replication/logical/logicalctl.c

DisableLogicalDecodingIfNecessary:

2.
+ /*
+ * Sanity check as we cannot disable logical decoding while holding a
+ * logical slot.
+ */
+ Assert(!MyReplicationSlot);

File header comment says, "While activation occurs synchronously right
after creating the first logical slot, deactivation happens
asynchronously through the checkpointer..."

Q. Is that new sanity-check Assert safe?

IOW, isn't it possible that some logical slot got created after the
checkpointer was requested to deactivate logical replication, but
before DisableLogicalDecodingIfNecessary() was called?

Or should that code be more like:

if (MyReplicationSlot)
return;

======
Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Smith 2025-10-24 03:03:49 PG18 GIN parallel index build crash - invalid memory alloc request size
Previous Message Jeff Davis 2025-10-24 02:37:25 Re: tiny step toward threading: reduce dependence on setlocale()