Hi,

On Thu, Nov19, 2026 at 09:05 AM Chao Li wrote:


> On Nov 19, 2026, at 07:46, Joao Rito <[email protected]> wrote:
>
> Two errors tell the user that wal_level must be at least "replica"
> but give no hint on how to fix it. The similar errors for existing
> slots in RestoreSlotFromDisk() already say:
>
>     Change "wal_level" to be "replica" or higher.
>
> Add that hint to the error in CheckSlotRequirements() and to the one
> in pg_log_standby_snapshot(). Since wal_level can only be changed at
> server start, also tell the user to restart, using the wording of a
> hint in xlogrecovery.c:
>
>     Restart the server after making the necessary configuration changes.
>
> "replica" is enough for every caller of CheckSlotRequirements(),
> including REPACK, which has its own check in
> check_concurrent_repack_requirements() that also asks for "replica"
> or higher.
> ---
>
> src/backend/access/transam/xlogfuncs.c | 3 ++-
> src/backend/replication/slot.c         | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/backend/access/transam/xlogfuncs.c 
b/src/backend/access/transam/xlogfuncs.c
> index 1f52bf7..4ec42c4 100644
> --- a/src/backend/access/transam/xlogfuncs.c
> +++ b/src/backend/access/transam/xlogfuncs.c
> @@ -243,7 +243,8 @@ pg_log_standby_snapshot(PG_FUNCTION_ARGS)
> if (!XLogStandbyInfoActive())
> ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> - errmsg("pg_log_standby_snapshot() can only be used if \"wal_level\" >= 
\"replica\"")));
> + errmsg("pg_log_standby_snapshot() can only be used if \"wal_level\" >= 
\"replica\""),
> + errhint("Change \"wal_level\" to be \"replica\" or higher. Restart the server 
after making the necessary configuration changes.")));
>
> recptr = LogStandbySnapshot();
>
> diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
> index a311aee..64f4578 100644
> --- a/src/backend/replication/slot.c
> +++ b/src/backend/replication/slot.c
> @@ -1690,7 +1690,8 @@ CheckSlotRequirements(bool repack)
> if (wal_level < WAL_LEVEL_REPLICA)
> ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> - errmsg("replication slots can only be used if \"wal_level\" >= 
\"replica\"")));
> + errmsg("replication slots can only be used if \"wal_level\" >= 
\"replica\""),
> + errhint("Change \"wal_level\" to be \"replica\" or higher. Restart the server 
after making the necessary configuration changes.")));
> }
>

I’m not against adding the hint message. I think the hint message can
be shorter, and there should be two white spaces between sentences.
So, how about: ``` errhint("Set \"wal_level\" to \"replica\" or higher
and restart the server.") ```

I don't think these two errors need an additional hint, as the primary error messages here already explicitly state the required setting and value ("... can only be used if \"wal_level\" >= \"replica\""). Repeating that in errhint() would be redundant.

--
Best Regards,
Zhijie Hou


Reply via email to