Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
Shlok Kyal <shlok.kyal.oss@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>,
shveta malik <shveta.malik@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-09-11T06:32:12Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix regression test failure when wal_level is set to minimal.
- 0de5f0d869d1 19 (unreleased) landed
-
Toggle logical decoding dynamically based on logical slot presence.
- 67c20979ce72 19 (unreleased) landed
-
Disallow server start with sync_replication_slots = on and wal_level < logical.
- 12da45742cfd 19 (unreleased) cited
On Sat, Sep 6, 2025 at 3:46 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> I've attached the updated patch that incorporated all comments I got so far.
>
*
+ /*
+ * While all processes are using the new status, there could be some
+ * transactions that might have started with the old status. So wait
+ * for the running transactions to complete so that logical decoding
+ * doesn't include transactions that wrote WAL with insufficient
+ * information.
+ */
+ running = GetRunningTransactionData();
+ LWLockRelease(ProcArrayLock);
+ LWLockRelease(XidGenLock);
+
+ elog(DEBUG1, "waiting for %d transactions to complete", running->xcnt);
+
+ for (int i = 0; i < running->xcnt; i++)
+ {
+ TransactionId xid = running->xids[i];
+
+ if (TransactionIdIsCurrentTransactionId(xid))
+ continue;
+
+ XactLockTableWait(xid, NULL, NULL, XLTW_None);
+ }
When building a snapshot during the start of logical decoding, we
anyway wait for running transactions to finish via the snapbuild
machinery. So, why do we need it here? And if it is needed, can we
update the comments to explain why it is required in spite of
snapbuild machinery doing similar thing?
* Is it a good idea to enable/disable decoding for temporary logical
slots? The temporary slots are released during ERROR or at session
end, is that a good time to do the disable processing that even
requires WAL writing.
--
With Regards,
Amit Kapila.