mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user