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: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-05-07T06:59:10Z
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 Thu, Apr 24, 2025 at 11:14 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > On Thu, Apr 24, 2025 at 5:30 AM Amit Kapila <amit.kapila16@gmail.com> wrote: > > > > On Wed, Apr 23, 2025 at 9:35 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > > > > > On Wed, Apr 23, 2025 at 5:46 AM Amit Kapila <amit.kapila16@gmail.com> wrote: > > > > > > > > BTW, did we consider the idea to automatically transition to 'logical' > > > > when the first logical slot is created and transition back to > > > > 'replica' when last logical slot gets dropped? I see some ideas around > > > > this last time we discussed this topic. > > > > > > Yes. Bertrand pointed out that a drawback is that the primary server > > > needs to create a logical slot in order to execute logical decoding on > > > the standbys[1]. > > > > > > > True, but if we want to avoid that, we can still keep 'logical' as > > wal_level for the ease of users. > > I think we'd like to cover the use case like where users start with > 'replica' on the primary and execute logical decoding on the standby > without neither creating a logical slot on the primary nor restarting > the primary. > Okay, if we introduce a SIGHUP GUC like max_wal_level as you are proposing, the above requirement will be fulfilled, right? The other way is by API pg_activate_logical_decoding(). > > We can also have another API like the > > one you originally proposed (pg_activate_logical_decoding) for the > > ease of users. But the minimum requirement would be that one creates a > > logical slot to enable logical decoding/replication. > > I think we want to avoid the runtime WAL level automatically decreased > to 'replica' once all logical slots are removed, if users still want > to execute logical decoding on only the standby. One idea is that if > users enable logical decoding using pg_activate_logical_decoding(), > the runtime WAL level doesn't decrease to 'replica' even if all > logical slots are removed. > That makes sense. If we are using an API like pg_activate_*/pg_deactivate_*, then why add an additional dependency on the slots? -- With Regards, Amit Kapila.