Thread: [HACKERS] The error message "sorry, too many clients already" is imprecise

[HACKERS] The error message "sorry, too many clients already" is imprecise

From
Piotr Stefaniak
Date:
I recently started getting the "sorry, too many clients already" error.
There are currently four places that can generate it, but fortunately
log_error_verbosity was set to verbose so I was able to see that in this
case the warning was generated by proc.c:InitProcess().

But it's still not much, because there are three different lists you can
run out of and get the same error message from InitProcess(). I was
lucky to be able to rule out two of them. max_connections is set to much
more than the sum of possible connections from all relevant pgBouncer
instances we have, so it's not hitting max_connections. Also, this is on
9.4 and we don't use any funny extensions, so it's probably not running
out of bgworkerFreeProcs either. autovacFreeProcs is what's left but
this is still just a guess and I'd prefer to actually know.

I've made a hack for myself (attached diff against 9.4) which adds a
DETAIL-level message telling me which proc list was saturated. It's not
committable in its current form because of a C99 feature and perhaps for
other reasons.

By the way, I've also noticed that the InitProcess() can segfault upon
hitting set_spins_per_delay(procglobal->spins_per_delay). This only
happens when I run REL9_4_STABLE under gdb, set a breakpoint on
InitProcess, see an autovacuum launcher hit the breakpoint and tell gdb
to continue. "p procglobal->spins_per_delay" says "Cannot access memory
at address 0xf01b2f90". Maybe this means nothing.

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

Re: [HACKERS] The error message "sorry, too many clients already" isimprecise

From
Peter Eisentraut
Date:
On 8/8/17 06:39, Piotr Stefaniak wrote:
> I've made a hack for myself (attached diff against 9.4) which adds a
> DETAIL-level message telling me which proc list was saturated. It's not
> committable in its current form because of a C99 feature and perhaps for
> other reasons.

There are other places that also emit the "sorry" message that would
also need to be looked at.  Also, the patch would need to be against master.

This kind of patch to make error messages more precise is usually
welcome, so keep working on it.  But this needs a bit more refinement as
it stands.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services