| From: | vignesh C <vignesh21(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Peter Smith <smithpb2250(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-12-02 08:53:15 |
| Message-ID: | CALDaNm29FrTfpNB=j2mum8_goGQ1Ou2GR4z58nGs+-o6B1+=vg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, 1 Dec 2025 at 12:33, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Mon, Dec 1, 2025 at 12:20 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> I've attached the patch. All the comments I got so far have been
> addressed in this version unless I'm missing something.
Few comments:
1) We have an invalidation test at 044_invalidate_inactive_slots.pl
which does an equivalent of this, I felt this can be removed and just
the test_wal_level can be done from 044_invalidate_inactive_slots:
+# Add other settings to test if we disable logical decoding when
invalidating the last
+# logical slot.
+$primary->append_conf(
+ 'postgresql.conf',
+ qq[
+min_wal_size = 32MB
+max_wal_size = 32MB
+max_slot_wal_keep_size = 16MB
+]);
+$primary->start;
+
+# Advance WAL and check if the slot gets invalidated.
+$primary->advance_wal(2);
+$primary->safe_psql('postgres', qq[CHECKPOINT]);
+is( $primary->safe_psql(
+ 'postgres',
+ qq[
+select invalidation_reason = 'wal_removed' from pg_replication_slots
where slot_name = 'test_slot';
+ ]),
+ 't',
+ 'test_slot gets invalidated due to wal_removed');
+
+# Check if logical decoding is disabled after invalidating the last
logical slot.
+wait_for_logical_decoding_disabled($primary);
+test_wal_level($primary, "replica|replica",
+ "effective_wal_level got decreased to 'replica' after
invalidating the last logical slot"
+);
+# Recreate the logical slot to enable logical decoding again.
+$primary->safe_psql('postgres',
+ qq[select pg_drop_replication_slot('test_slot')]);
+$primary->safe_psql('postgres',
+ qq[select pg_create_logical_replication_slot('test_slot', 'pgoutput')]);
2) What are we verifying here, as a logical replication slot can be
created without promotion too:
# Confirm if we can create a logical slot after the promotion.
$standby1->safe_psql('postgres',
qq[select pg_create_logical_replication_slot('standby1_slot2', 'pgoutput')]
);
If it is not required we can remove it.
3) This message seems wrong:
+ "cannot server with wal_level='minimal' as there is in-use
logical slot");
+
+my $logfile = slurp_file($primary->logfile());
Should it be:
cannot start server with wal_level='minimal'
Regards,
Vignesh
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rahila Syed | 2025-12-02 08:58:29 | Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations |
| Previous Message | Daniel Gustafsson | 2025-12-02 08:31:34 | Re: Remove unused function parameters, part 2: replication |