remove check hooks for GUCs that contribute to MaxBackends

Started by Nathan Bossartover 1 year ago5 messages
Jump to latest
#1Nathan Bossart
nathandbossart@gmail.com

While working on an idea from another thread [0]/messages/by-id/20240618213331.ef2spg3nasksisbi@awork3.anarazel.de, I noticed that each of
max_connections, max_worker_process, max_autovacuum_workers, and
max_wal_senders have a check hook that verifies the sum of those GUCs does
not exceed a certain value. Then, in InitializeMaxBackends(), we do the
same check once more. Not only do the check hooks seem redundant, but I
think they might sometimes be inaccurate since some values might not yet be
initialized. Furthermore, the error message is not exactly the most
descriptive:

$ pg_ctl -D . start -o "-c max_connections=262100 -c max_wal_senders=10000"

FATAL: invalid value for parameter "max_wal_senders": 10000

The attached patch removes these hooks and enhances the error message to
look like this:

FATAL: too many backends configured
DETAIL: "max_connections" (262100) plus "autovacuum_max_workers" (3) plus "max_worker_processes" (8) plus "max_wal_senders" (10000) must be less than 262142.

The downside of this change is that server startup progresses a little
further before it fails, but that might not be too concerning given this
_should_ be a relatively rare occurrence.

Thoughts?

[0]: /messages/by-id/20240618213331.ef2spg3nasksisbi@awork3.anarazel.de

--
nathan

Attachments:

v1-0001-remove-check-hooks-for-GUCs-that-contribute-to-Ma.patchtext/plain; charset=us-asciiDownload+11-61
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nathan Bossart (#1)
Re: remove check hooks for GUCs that contribute to MaxBackends

Nathan Bossart <nathandbossart@gmail.com> writes:

While working on an idea from another thread [0], I noticed that each of
max_connections, max_worker_process, max_autovacuum_workers, and
max_wal_senders have a check hook that verifies the sum of those GUCs does
not exceed a certain value. Then, in InitializeMaxBackends(), we do the
same check once more. Not only do the check hooks seem redundant, but I
think they might sometimes be inaccurate since some values might not yet be
initialized.

Yeah, these per-variable checks are inherently bogus. If we can get
of them and make the net user experience actually better, that's a
win-win.

It seems easier to do for these because they can't change after server
start, so there can be one well-defined time to apply the consistency
check. IIRC, we have some similar issues in other hooks for variables
that aren't PGC_POSTMASTER, so it's harder to see how we might get rid
of their cross-checks. That doesn't make them less bogus though.

regards, tom lane

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nathan Bossart (#1)
Re: remove check hooks for GUCs that contribute to MaxBackends

Nathan Bossart <nathandbossart@gmail.com> writes:

The attached patch removes these hooks and enhances the error message to
look like this:

FATAL: too many backends configured
DETAIL: "max_connections" (262100) plus "autovacuum_max_workers" (3) plus "max_worker_processes" (8) plus "max_wal_senders" (10000) must be less than 262142.

BTW, I suggest writing it as "too many server processes configured",
or perhaps "too many server processes required". "Backend" is too
much of an insider term.

regards, tom lane

#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#3)
Re: remove check hooks for GUCs that contribute to MaxBackends

On Wed, Jun 19, 2024 at 03:14:16PM -0400, Tom Lane wrote:

Nathan Bossart <nathandbossart@gmail.com> writes:

The attached patch removes these hooks and enhances the error message to
look like this:

FATAL: too many backends configured
DETAIL: "max_connections" (262100) plus "autovacuum_max_workers" (3) plus "max_worker_processes" (8) plus "max_wal_senders" (10000) must be less than 262142.

BTW, I suggest writing it as "too many server processes configured",
or perhaps "too many server processes required". "Backend" is too
much of an insider term.

Will do, thanks for reviewing.

--
nathan

#5Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#4)
Re: remove check hooks for GUCs that contribute to MaxBackends

Committed.

--
nathan