mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
Be more careful about GucSource for internally-driven GUC settings.
The original advice for hard-wired SetConfigOption calls was to use PGC_S_OVERRIDE, particularly for PGC_INTERNAL GUCs. However, that's really overkill for PGC_INTERNAL GUCs, since there is no possibility that we need to override a user-provided setting. Instead use PGC_S_DYNAMIC_DEFAULT in most places, so that the value will appear with source = 'default' in pg_settings and thereby not be shown by psql's new \dconfig command. The one exception is that when changing in_hot_standby in a hot-standby session, we still use PGC_S_OVERRIDE, because people felt that seeing that in \dconfig would be a good thing. Similarly use PGC_S_DYNAMIC_DEFAULT for the auto-tune value of wal_buffers (if possible, that is if wal_buffers wasn't explicitly set to -1), and for the typical 2MB value of max_stack_depth. In combination these changes remove four not-very-interesting entries from the typical output of \dconfig, all of which people fingered as "why is that showing up?" in the discussion thread. Discussion: https://postgr.es/m/3118455.1649267333@sss.pgh.pa.us
This commit is contained in:
@@ -5939,6 +5939,8 @@ InitializeGUCOptionsFromEnvironment(void)
|
||||
* rlimit isn't exactly an "environment variable", but it behaves about
|
||||
* the same. If we can identify the platform stack depth rlimit, increase
|
||||
* default stack depth setting up to whatever is safe (but at most 2MB).
|
||||
* Report the value's source as PGC_S_DYNAMIC_DEFAULT if it's 2MB, or as
|
||||
* PGC_S_ENV_VAR if it's reflecting the rlimit limit.
|
||||
*/
|
||||
stack_rlimit = get_stack_depth_rlimit();
|
||||
if (stack_rlimit > 0)
|
||||
@@ -5947,12 +5949,19 @@ InitializeGUCOptionsFromEnvironment(void)
|
||||
|
||||
if (new_limit > 100)
|
||||
{
|
||||
GucSource source;
|
||||
char limbuf[16];
|
||||
|
||||
new_limit = Min(new_limit, 2048);
|
||||
sprintf(limbuf, "%ld", new_limit);
|
||||
if (new_limit < 2048)
|
||||
source = PGC_S_ENV_VAR;
|
||||
else
|
||||
{
|
||||
new_limit = 2048;
|
||||
source = PGC_S_DYNAMIC_DEFAULT;
|
||||
}
|
||||
snprintf(limbuf, sizeof(limbuf), "%ld", new_limit);
|
||||
SetConfigOption("max_stack_depth", limbuf,
|
||||
PGC_POSTMASTER, PGC_S_ENV_VAR);
|
||||
PGC_POSTMASTER, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6776,12 +6785,16 @@ BeginReportingGUCOptions(void)
|
||||
reporting_enabled = true;
|
||||
|
||||
/*
|
||||
* Hack for in_hot_standby: initialize with the value we're about to send.
|
||||
* Hack for in_hot_standby: set the GUC value true if appropriate. This
|
||||
* is kind of an ugly place to do it, but there's few better options.
|
||||
*
|
||||
* (This could be out of date by the time we actually send it, in which
|
||||
* case the next ReportChangedGUCOptions call will send a duplicate
|
||||
* report.)
|
||||
*/
|
||||
in_hot_standby = RecoveryInProgress();
|
||||
if (RecoveryInProgress())
|
||||
SetConfigOption("in_hot_standby", "true",
|
||||
PGC_INTERNAL, PGC_S_OVERRIDE);
|
||||
|
||||
/* Transmit initial values of interesting variables */
|
||||
for (i = 0; i < num_guc_variables; i++)
|
||||
@@ -6822,15 +6835,8 @@ ReportChangedGUCOptions(void)
|
||||
* transition from false to true.
|
||||
*/
|
||||
if (in_hot_standby && !RecoveryInProgress())
|
||||
{
|
||||
struct config_generic *record;
|
||||
|
||||
record = find_option("in_hot_standby", false, false, ERROR);
|
||||
Assert(record != NULL);
|
||||
record->status |= GUC_NEEDS_REPORT;
|
||||
report_needed = true;
|
||||
in_hot_standby = false;
|
||||
}
|
||||
SetConfigOption("in_hot_standby", "false",
|
||||
PGC_INTERNAL, PGC_S_OVERRIDE);
|
||||
|
||||
/* Quick exit if no values have been changed */
|
||||
if (!report_needed)
|
||||
|
Reference in New Issue
Block a user