From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Jacob Brazeal <jacob.brazeal@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: MAX_BACKENDS size (comment accuracy)
Date: Mon, 24 Feb 2025 13:52:51 -0600
Message-ID: <Z7zOEzz8lNjaU9yf@nathan> (raw)
In-Reply-To: <6gs5nstss3fgb5gxd7vl6wszituul7damayktsypolmbx6hzei@2uxvnjnq3xy6>
References: <CA+COZaAWNqVTSYuYxECm4ZgD6hszTWTJhTV06B5yLdoOHT1Yzw@mail.gmail.com>
<wptizm4qt6yikgm2pt52xzyv6ycmqiutloyvypvmagn7xvqkce@d4xuv3mylpg4>
<7bye3hvkdk7ybt4ofigimr4ahshsj657aqatfc5trd5pbp5qd4@dir2wsx2lgo6>
<CA+COZaDDM4YTdei2qhGie1RFTCmpJEsgQmR3x1vngKy62gFjuQ@mail.gmail.com>
<CA+COZaAURmfeXjgsFSr2TWRa6r0PYVhf=FVEeEdVGx13VWSyqw@mail.gmail.com>
<riivolmg6uzfvpzfn6wjo3ghwt42rcec43ok6mv4oenfg654y7@x7dbposbskwd>
<CA+hUKGKDdkE_dvaJNiq1SEP8nibX4w+M85ksaoS91Ayy2+Uhiw@mail.gmail.com>
<rg5rpyqzlsost6y7d7njw5omzdkiql7adxqubmpbng4urvo7qb@ioe7et2imvp2>
<CA+hUKG+nc8=0i1jfQM0wLMXnf4DUses_dxdqpPUVfXamZ3ZdZg@mail.gmail.com>
<6gs5nstss3fgb5gxd7vl6wszituul7damayktsypolmbx6hzei@2uxvnjnq3xy6>
The recent commits for this drew my attention to the comment for
MAX_BACKENDS. Specifically, it says we check the value in
RegisterBackgroundWorker() (which appears to have been untrue since we
added max_worker_processes) and relevant GUC check hooks (which I removed
last year in commit 0b1fe14). I wrote a short patch to fix this, which I
intend to commit soon unless there is feedback.
--
nathan
Attachments:v1-0001-Fix-comment-for-MAX_BACKENDS.patch (text/plain, 1.5K) download
From 5038a5256942999bd544879d25312338686dddf2 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Mon, 24 Feb 2025 13:40:30 -0600
Subject: [PATCH v1 1/1] Fix comment for MAX_BACKENDS.
This comment mentions that we check the configured number of
backends does not exceed MAX_BACKENDS in RegisterBackgroundWorker()
and relevant GUC check hooks, neither of which is true anymore. To
fix, adjust this comment to state that we do the check in
InitializeMaxBackends().
Oversights in commits 6bc8ef0b7f and 0b1fe1413e.
---
src/include/storage/procnumber.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/include/storage/procnumber.h b/src/include/storage/procnumber.hindex 75c2c7a17c0..2ddaaf0c646 100644--- a/src/include/storage/procnumber.h+++ b/src/include/storage/procnumber.h@@ -32,8 +32,8 @@ typedef int ProcNumber;
* currently realistic configurations. Even if that limitation were removed,
* we still could not a) exceed 2^23-1 because inval.c stores the ProcNumber
* as a 3-byte signed integer, b) INT_MAX/4 because some places compute
- * 4*MaxBackends without any overflow check. This is rechecked in the- * relevant GUC check hooks and in RegisterBackgroundWorker().+ * 4*MaxBackends without any overflow check. We check that the configured+ * number of backends does not exceed MAX_BACKENDS in InitializeMaxBackends().
*/
#define MAX_BACKENDS_BITS 18
#define MAX_BACKENDS ((1U << MAX_BACKENDS_BITS)-1)
--
2.39.5 (Apple Git-154)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, andres@anarazel.de, thomas.munro@gmail.com, jacob.brazeal@gmail.com
Subject: Re: MAX_BACKENDS size (comment accuracy)
In-Reply-To: <Z7zOEzz8lNjaU9yf@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox