[PATCH] pg_createsubscriber: add hint to wal_level error

Started by Joao Rito3 days ago3 messageshackers
Jump to latest
#1Joao Rito
joaovictor.rito@gmail.com

The error reported when the publisher has wal_level = minimal says what
is required but not how to fix it. The neighboring errors about
max_replication_slots and max_wal_senders already carry a hint. Add one
here, using the wording of the equivalent hint in slot.c.
---
Hi,

I may have missed something, so please correct me where I am wrong.

When the publisher has wal_level = minimal, pg_createsubscriber says what is required but not how to fix it:

pg_createsubscriber: error: publisher requires "wal_level" >= "replica"

The next checks in check_publisher(), for max_replication_slots and max_wal_senders, already print a hint. The attached patch adds a hint here, with the same wording as the errhint in slot.c:

pg_createsubscriber: hint: Change "wal_level" to be "replica" or higher.

I tested on current master (8303f2e) with --enable-cassert and --enable-tap-tests. I ran pg_createsubscriber --dry-run against a primary with wal_level=minimal. The hint appears after the patch and not before. "make check" in src/bin/pg_basebackup passed (362 tests, including 040_pg_createsubscriber), and pgindent shows no diff.

What I did not test: translations (--enable-nls), meson, other platforms, and whether this was already discussed on the list. I did not add a regression test, because I found no existing test that checks this message.

Does this make sense? If the hint is redundant or the wording should change, I am happy to adjust or drop the patch.

Thank you for your time.
src/bin/pg_basebackup/pg_createsubscriber.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 20b354a..8a84bcf 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -1092,6 +1092,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
 	if (strcmp(wal_level, "minimal") == 0)
 	{
 		pg_log_error("publisher requires \"wal_level\" >= \"replica\"");
+		pg_log_error_hint("Change \"wal_level\" to be \"replica\" or higher.");
 		failed = true;
 	}

--
2.39.5

#2Hayato Kuroda (Fujitsu)
kuroda.hayato@fujitsu.com
In reply to: Joao Rito (#1)
RE: [PATCH] pg_createsubscriber: add hint to wal_level error

Hi,

To clarify, the same logic as [1]/messages/by-id/OS7PR01MB18317465AC53232FAB8E62BFCF5792@OS7PR01MB18317.jpnprd01.prod.outlook.com is here. Since the error message contains
enough info, -1 to add HINT.

[1]: /messages/by-id/OS7PR01MB18317465AC53232FAB8E62BFCF5792@OS7PR01MB18317.jpnprd01.prod.outlook.com

Best regards,
Hayato Kuroda
FUJITSU LIMITED

#3Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Joao Rito (#1)
Re: [PATCH] pg_createsubscriber: add hint to wal_level error

Hello,

At Wed, 18 Nov 2026 22:45:13 -0300, Joao Rito <joaovictor.rito@gmail.com> wrote in

The error reported when the publisher has wal_level = minimal says what
is required but not how to fix it. The neighboring errors about
max_replication_slots and max_wal_senders already carry a hint. Add one
here, using the wording of the equivalent hint in slot.c.

pg_log_error("publisher requires \"wal_level\" >= \"replica\"");
+ pg_log_error_hint("Change \"wal_level\" to be \"replica\" or higher.");

I don't particularly think this is necessary, since the main message
already clearly states the requirement. However, a quick search turned
up a few other messages worth looking at in this context.

Here are a few observations.

1. We could perhaps make the following messages clearer by specifying
the required values directly in the main messages, rather than in
the hints or details.

./backend/access/transam/xlog.c:10003:
errmsg("WAL level not sufficient for making an online backup"),
errhint("\"wal_level\" must be set to \"replica\" or \"logical\" at server start.")));
./backend/access/transam/xlog.c:10339:
errmsg("WAL level not sufficient for making an online backup"),
errhint("\"wal_level\" must be set to \"replica\" or \"logical\" at server start.")));
./backend/commands/repack.c:983:
errmsg("cannot execute %s in this configuration",
errdetail("This operation requires \"wal_level\" to be set to \"replica\" or higher."));
./backend/commands/subscriptioncmds.c:3513:
errmsg("cannot execute %s in this configuration",
errdetail("This operation requires \"wal_level\" to be set to \"replica\" or higher."));

2. There are many messages like the following, where the hint seems to
repeat part of the requirement already stated in the main message.
However, I don't see much need to change them.

./backend/replication/logical/logical.c:172:
errmsg("logical decoding on standby requires \"effective_wal_level\" >= \"logical\" on the primary"),
errhint("Set \"wal_level\" >= \"logical\" or create at least one logical slot when \"wal_level\" = \"replica\".")));

3. The main message and hint in the following case don't seem quite
aligned: the former refers to replication slot synchronization, while
the latter refers to logical decoding.

./backend/replication/logical/slotsync.c:1265:
errmsg("replication slot synchronization requires \"effective_wal_level\" >= \"logical\" on the primary"),
errhint("To enable logical decoding on primary, set \"wal_level\" >= \"logical\" or create at least one logical slot when \"wal_level\" = \"replica\"."));

There may be more examples, but these are just a few that caught my
attention.

Regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center