Better error messages when lacking connection slots for autovacuum workers and bgworkers

Started by Michael Paquierover 7 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t40115
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 28, 2026 at 04:38 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t40115_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t40115_1 && git checkout t40115_1

Patchset v1 (message #1) is on t40115_1

Jump to latest
#1Michael Paquier
michael@paquier.xyz

Hi all,

When lacking connection slots, the backend returns a simple "sorry,
too many clients", which is something that has been tweaked by recent
commit ea92368 for WAL senders. However, the same message would show
up for autovacuum workers and bgworkers. Based on the way autovacuum
workers are spawned by the launcher, and the way bgworkers are added,
it seems that this cannot actually happen. Still, in my opinion,
providing more context can be helpful for people trying to work on
features related to such code so as they can get more information than
what would normally happen for normal backends.

I am wondering as well if this could not help for issues like this
one, which has popped out today and makes me wonder if we don't have
race conditions with the way dynamic bgworkers are spawned:
/messages/by-id/CAONUJSM5X259vAnnwSpqu=VnRECfGSJ-CgRHyS4P5YyRVwkXsQ@mail.gmail.com

There are four code paths which report the original "sorry, too many
clients", and the one of the patch attached can easily track the
type of connection slot used which helps for better context messages
when a process is initialized.

Would that be helpful for at least debugging purposes?

Thanks,
--
Michael

Attachments:

t40115_1
connslot-error-context-v1.patchtext/x-diff; charset=us-asciiDownload+13-3
#2Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Michael Paquier (#1)
Re: [Suspect SPAM] Better error messages when lacking connection slots for autovacuum workers and bgworkers

Hello.

At Wed, 13 Feb 2019 14:13:09 +0900, Michael Paquier <michael@paquier.xyz> wrote in <20190213051309.GF5746@paquier.xyz>

Hi all,

When lacking connection slots, the backend returns a simple "sorry,
too many clients", which is something that has been tweaked by recent
commit ea92368 for WAL senders. However, the same message would show
up for autovacuum workers and bgworkers. Based on the way autovacuum
workers are spawned by the launcher, and the way bgworkers are added,
it seems that this cannot actually happen. Still, in my opinion,
providing more context can be helpful for people trying to work on
features related to such code so as they can get more information than
what would normally happen for normal backends.

I agree to the distinctive messages, but the autovaccum and
bgworker cases are in a kind of internal error, and they are not
"connection"s. I feel that elog is more suitable for them.

I am wondering as well if this could not help for issues like this
one, which has popped out today and makes me wonder if we don't have
race conditions with the way dynamic bgworkers are spawned:
/messages/by-id/CAONUJSM5X259vAnnwSpqu=VnRECfGSJ-CgRHyS4P5YyRVwkXsQ@mail.gmail.com

There are four code paths which report the original "sorry, too many
clients", and the one of the patch attached can easily track the
type of connection slot used which helps for better context messages
when a process is initialized.
Would that be helpful for at least debugging purposes?

I agree that it is helpful. Errors with different causes ought to
show distinctive error messages.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#3Michael Paquier
michael@paquier.xyz
In reply to: Kyotaro Horiguchi (#2)
Re: [Suspect SPAM] Better error messages when lacking connection slots for autovacuum workers and bgworkers

On Thu, Feb 14, 2019 at 09:04:37PM +0900, Kyotaro HORIGUCHI wrote:

I agree to the distinctive messages, but the autovaccum and
bgworker cases are in a kind of internal error, and they are not
"connection"s. I feel that elog is more suitable for them.

I used ereport() for consistency with the existing code, still you are
right that we ought to use elog() as this is the case of a problem
which should not happen.
--
Michael