Johan Svensson <johan.svensson@windh.net> writes:
> The PostgreSQL console prints a lot of "DEBUG: pq_recvbuf: unexpected
> EOF on client connection" and one "FATAL 1: Sorry, too many clients
> already" causing the exception on our side.
> It works with a delay after each completed transaction, but we cannot
> have such a delay since it will decrease performance too much. Any ideas
> why a delay is needed?
It does take a finite (and not small) amount of time for a backend to
clean up and exit after it detects client closure of the connection.
It looks like you're managing to spawn connections fast enough that
the not-yet-exited backends are filling all your available backend
slots.
If you are concerned about performance, why in the world are you
starting a new connection for every transaction anyway? Talk about
self-inflicted damage ... set up a connection pool, man.
regards, tom lane