| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | Amit Kapila <amit(dot)kapila16(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>, shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Subject: | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |
| Date: | 2025-11-27 09:50:57 |
| Message-ID: | CAJpy0uA_aQyii87ZWD4E7pLN9fwfds0suLgvbgGoOYjEzUEn3Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Nov 27, 2025 at 2:32 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
>
> I've squashed all fixup patches and attached the updated patch.
>
Thanks for test results and the patch. Please find a few comments:
1)
If primary has effective_wal_level as logical and standby has zero
slots; then during promotion of standby, if I try to create a slot, it
is restricted as intended, but it gives misleading message:
postgres=# SELECT pg_create_logical_replication_slot('slot',
'pgoutput', false, false, false);
ERROR: logical decoding on standby requires "effective_wal_level" >=
"logical" on the primary
HINT: Set "wal_level" >= "logical" or create at least one logical
slot when "wal_level" = "replica".
One possibility is we extend the message as follows:
"Logical decoding on standby requires either effective_wal_level >=
logical on the primary or that recovery has finished." and remove
errhint?
2)
+ * completes. Here's how we handle concurrent toggling logical decoding:
toggling --> toggling of
3)
+ /*
+ * This is the authoritative value used by all processes to determine
+ * whether to write additional information required by logical decoding to
+ * WAL. Since this information could be checked frequently, each process
+ * caches this value in XLogLogicalInfo for better performance.
+ */
+ bool xlog_logical_info;
Shall we mention about cache XLogLogicalInfoXactCache as well here?
4)
EnsureLogicalDecodingEnabled():
+ if (wal_level == WAL_LEVEL_MINIMAL)
+ ereport(ERROR,
+ errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("cannot enable logical decoding when \"wal_level\" = \"minimal\""));
Do we need this error here? CheckSlotRequirements checks this already.
Won't Assert suffice here?
5)
EnsureLogicalDecodingEnabled():
+ if (RecoveryInProgress())
+ {
+ Assert(IsLogicalDecodingEnabled());
+ return;
+ }
I understand that it will be no-op on standby. But it took me some
time to understand why we expect logical-decoding enabled here. I see
that CheckLogicalDecodingRequirements() won't allow the flow to reach
here if logical-decoding was not enabled in the first place. Shall we
add some comments here?
6)
DisableLogicalDecodingIfNecessary() has this:
+ if (wal_level != WAL_LEVEL_REPLICA)
+ return;
Also it has this:
+ /* Write the WAL to disable logical decoding on standbys too */
+ if (XLogStandbyInfoActive())
+ write_logical_decoding_status_update_record(false);
Do we actually need XLogStandbyInfoActive() here? Given that wal_level
is replica, and we’ve already confirmed that no slot exists while
pending_disable and xlog_logical_info are still true, isn’t that
enough to write a WAL record for the disable operation?
7)
+ /*
+ * With 'minimal' WAL level, there are not logical replication slots
+ * during recovery. Logical decoding is always disabled, so there is no
+ * need to synchronize XLogLogicalInfo..
+ */
not -> no
2 dots at the end.
=====
Reviewing more..
thanks
Shveta
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Silitskiy | 2025-11-27 10:19:13 | Re: Exit walsender before confirming remote flush in logical replication |
| Previous Message | Aleksander Alekseev | 2025-11-27 09:44:18 | Re: change default default_toast_compression to lz4? |