diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2023-08-28 15:15:20 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2023-08-28 15:17:04 +0200 |
commit | 36e4419d1f1ef06bba58a28a870aaaa8de73bb46 (patch) | |
tree | 9884e1cad81ae0aab5e7aba9f6d9bf676b8a7a3f /src/backend/access/transam/xlog.c | |
parent | bb9002257b2211c213ad5989446d83a61c6446d3 (diff) | |
download | postgresql-36e4419d1f1ef06bba58a28a870aaaa8de73bb46.tar.gz postgresql-36e4419d1f1ef06bba58a28a870aaaa8de73bb46.zip |
Make error messages about WAL segment size more consistent
Make the primary messages more compact and make the detail messages
uniform. In initdb.c and pg_resetwal.c, use the newish
option_parse_int() to simplify some of the option parsing. For the
backend GUC wal_segment_size, add a GUC check hook to do the
verification instead of coding it in bootstrap.c. This might be
overkill, but that way the check is in the right place and it becomes
more self-documenting.
In passing, make pg_controldata use the logging API for warning
messages.
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://www.postgresql.org/message-id/flat/9939aa8a-d7be-da2c-7715-0a0b5535a1f7@eisentraut.org
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 60c0b7ec3af..f6f8adc72a6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1995,6 +1995,18 @@ assign_checkpoint_completion_target(double newval, void *extra) CalculateCheckpointSegments(); } +bool +check_wal_segment_size(int *newval, void **extra, GucSource source) +{ + if (!IsValidWalSegSize(*newval)) + { + GUC_check_errdetail("The WAL segment size must be a power of two between 1 MB and 1 GB."); + return false; + } + + return true; +} + /* * At a checkpoint, how many WAL segments to recycle as preallocated future * XLOG segments? Returns the highest segment that should be preallocated. @@ -4145,10 +4157,11 @@ ReadControlFile(void) if (!IsValidWalSegSize(wal_segment_size)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg_plural("WAL segment size must be a power of two between 1 MB and 1 GB, but the control file specifies %d byte", - "WAL segment size must be a power of two between 1 MB and 1 GB, but the control file specifies %d bytes", + errmsg_plural("invalid WAL segment size in control file (%d byte)", + "invalid WAL segment size in control file (%d bytes)", wal_segment_size, - wal_segment_size))); + wal_segment_size), + errdetail("The WAL segment size must be a power of two between 1 MB and 1 GB."))); snprintf(wal_segsz_str, sizeof(wal_segsz_str), "%d", wal_segment_size); SetConfigOption("wal_segment_size", wal_segsz_str, PGC_INTERNAL, |