I have observed the following same situation in PG 9.3beta1
Multiple PSQL clients are connected to server, some of them running  
transaction and some of them are idle state.

When one of the backend is killed or crashed (using kill -9 <backend-pid>).
The connection reset attempt from the active clients( that is, which were 
running a  transaction and crashed in between) fails, since they immediately 
make the attempt while the server is in startup phase.
I just gone through and found following:
1. When backend crashes , server goes into recovery mode and come in the  
normal state to accept connection, it take little time.
2. But at busy client(which was running transaction before crash),  immediately 
tries to reconnect to server which is under startup phase so it  gets a 
negative reply and fails to reconnect.
So I thought, before sending reconnect request from client need to wait for  
the server come to a state when it can accept connections.  It should have some 
timeout wait.
I am not sure is this correct way to code modification or does it have any 
other impact.
I tried wait to client before sending reconnect request to server.
For that added some sleep time for client in src/bin/psql/common.c (that is it 
changes things only  for psql clients)
Please check the attached patch for the modification.

Amul Sul

Attachment: 0001-psql-connection-reset-wait.patch
Description: Binary data

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

Reply via email to