| From: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Joao Rito <joaovictor(dot)rito(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] Add hint to wal_level errors for replication slots and pg_log_standby_snapshot |
| Date: | 2026-11-19 03:22:52 |
| Message-ID: | 9ee88f1d-931e-4a92-b0e8-052414f074b7@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Thu, Nov19, 2026 at 09:05 AM Chao Li wrote:
>
>
> > On Nov 19, 2026, at 07:46, Joao Rito <joaovictor(dot)rito(at)gmail(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joao Rito | 2026-11-19 03:26:53 | Re: [PATCH] pg_upgrade: add hints to wal_level and max_replication_slots checks |
| Previous Message | Joao Rito | 2026-11-19 03:12:02 | [PATCH] Reject empty string in option_parse_int() |