Re: Log a warning in pg_createsubscriber for max_slot_wal_keep_size - Mailing list pgsql-hackers

From Peter Smith
Subject Re: Log a warning in pg_createsubscriber for max_slot_wal_keep_size
Date
Msg-id CAHut+PsgEphCa-P-3Q7cORA=1TRv15UUsaxN9ZkX56M1-J_QRg@mail.gmail.com
Whole thread Raw
In response to Re: Log a warning in pg_createsubscriber for max_slot_wal_keep_size  (vignesh C <vignesh21@gmail.com>)
List pgsql-hackers
Hi Shubham.

Here are some review comments for the patch v3-0001.

======
Commit message.

1.
I can't pinpoint anything specifically wrong about this commit
message, but it seems to be repeating the same information over and
over.

======
Missing pg_createsubscriber documentation?

2.
I thought any prerequisite for 'max_slot_wal_keep_size' should be
documented here [1] along with the other setting requirements.

======
src/bin/pg_basebackup/pg_createsubscriber.c

3.
- " pg_catalog.current_setting('max_prepared_transactions')");
+ " pg_catalog.current_setting('max_prepared_transactions'),"
+ " pg_catalog.current_setting('max_slot_wal_keep_size')");

The code comment above this SQL looks like it should also mention the
'max_slot_wal_keep_size' value requirement.

~~~

4.
+/*
+ * Validate max_slot_wal_keep_size
+ * Logical replication requires max_slot_wal_keep_size to be set to -1 on the
+ * publisher to prevent the deletion of WAL files that are still needed by
+ * replication slots. If this parameter is set to a non-default value, it may
+ * cause replication failures due to required WAL files being
+ * prematurely removed.
+ */
+ if (dry_run && max_slot_wal_keep_size != -1)
+ {
+ pg_log_warning("publisher requires max_slot_wal_keep_size to be -1,
but is set to %d",
+    max_slot_wal_keep_size);
+ pg_log_warning_detail("Change the configuration parameter \"%s\" on
the publisher to %d.",
+   "max_slot_wal_keep_size", -1);
+ }
+

4a.
The code comment is not indented correctly.

~

4b.
It seems strange that the 'max_slot_wal_keep_size' GUC name is not
substituted in the pg_log_warning, but it is in the
pg_log_warning_detail.

Furthermore, GUC names appearing in messages should always be quoted.

~

4c.
Was there some reason to make this only a warning, instead of an error?

The risk "may cause replication failures" seems quite serious, so in
that case it might be a poor user experience if we are effectively
saying: "Too bad, it's all broken now; we warned you (only if you
tried a dry run), but you did not listen".

In other words, why not make this an error condition up-front to
entirely remove any chance of this failure?

======
[1] https://www.postgresql.org/docs/17/app-pgcreatesubscriber.html

Kind Regards,
Peter Smith.
Fujitsu Australia



pgsql-hackers by date:

Previous
From: "Jelte Fennema-Nio"
Date:
Subject: Re: RFC: Allow EXPLAIN to Output Page Fault Information
Next
From: David Rowley
Date:
Subject: Re: Add the ability to limit the amount of memory that can be allocated to backends.