Re: Should we say "wal_level = logical" instead of "wal_level >= logical"

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Should we say "wal_level = logical" instead of "wal_level >= logical"
Date: 2025-10-16 03:01:51
Message-ID: CAExHW5spvrnRX2xTV2U-CxvAt3uJiowekYWfaWVHqixzgFqC0A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 16, 2025 at 5:36 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Hi Hackers,
>
> While reviewing another LR thread [1] it saw multiple wal_level
> messages that seem more complex than necessary.
>
> Background: There are three wal_level values [2], ranked as:
> minimal < replica < logical
>
> Notice there is no wal_level "above" logical. Despite this, there are
> a number of places in the code and messages that say >= logical
> instead of just = logical. Here is a list:
>
> heapam.c
> - * This is only used in wal_level >= WAL_LEVEL_LOGICAL, and only for catalog
>
> xlog.c
> - * This returns true if wal_level >= logical and we are inside a valid
>
> tablecmds.c
> - /* should only get here if wal_level >= logical */
>
> slot.c
> - appendStringInfoString(&err_detail, _("Logical decoding on standby
> requires \"wal_level\" >= \"logical\" on the primary server."));
>
> decode.c
> - errmsg("logical decoding on standby requires \"wal_level\" >=
> \"logical\" on the primary")));
>
> logical.c
> - errmsg("logical decoding requires \"wal_level\" >= \"logical\"")));
> - errmsg("logical decoding on standby requires \"wal_level\" >=
> \"logical\" on the primary")));
>
> slotsync.c
> - * Logical slot sync/creation requires wal_level >= logical.
> - errmsg("replication slot synchronization requires \"wal_level\" >=
> \"logical\""));
>
> standby.c
> - if (wal_level >= WAL_LEVEL_LOGICAL && isCatalogRel)
> - if (wal_level >= WAL_LEVEL_LOGICAL)
> pg_createsubscriber.c
> - pg_log_error("publisher requires \"wal_level\" >= \"logical\"");
>
> xlog.h
> - #define XLogLogicalInfoActive() (wal_level >= WAL_LEVEL_LOGICAL)
>
> 035_standby_logical_decoding.pl
> - # We are not able to read from the slot as it requires wal_level >=
> logical on the primary server
> - "logical decoding on standby requires \"wal_level\" >= \"logical\"
> on the primary"
>
> ~~~
>
> IMO all these error messages appear more complicated than necessary.
>
> Isn't it simpler to say:
> "requires \"wal_level\" = \"logical\" ..."
>
> Instead of:
> "requires \"wal_level\" >= \"logical\" ..."
>
> ~~~
>
> FYI, there is other code that does not account for anything "above"
> logical. e.g.
> if (wal_level != WAL_LEVEL_LOGICAL)
>
> ~~~
>
> I propose to write a patch to change all those user-facing messages.
>
> What about changing the code/comments as well?
>
> Thoughts?

I think the reason it's phrased like that is because wal_level is
cumulative - higher wal_levels are assumed to cover all the functions
(and information) covered by lower wal levels. By phrasing it as
wal_level >= logical we are being future-proof. If we add another
level, we won't need to change documentation or error messages. But
you are right it might confuse users because they won't see anything
higher than logical. [1] is possibly changing that property of
wal_level values or at least threatening to change it and we don't
know what the next wal_level would be and whether it will continue to
cover lower levels. But maybe users are already used to that phrasing
since it seems be there for some time and without complaints. Did we
always use that wording for example, did pre-logical wal_level
messages also used wal_level >= replica?

--
Best Wishes,
Ashutosh Bapat

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-10-16 03:28:43 Re: doc: create table improvements
Previous Message jian he 2025-10-16 02:56:28 Re: speedup COPY TO for partitioned table.