Proposal to add connection request Wait-time in PSQL client. - Mailing list pgsql-hackers

From amul sul
Subject Proposal to add connection request Wait-time in PSQL client.
Date
Msg-id 1368750160.98161.YahooMailNeo@web193502.mail.sg3.yahoo.com
Whole thread Raw
Responses Re: Proposal to add connection request Wait-time in PSQL client.  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
Hello,

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
littletime. 
2. But at busy client(which was running transaction before crash),  immediately tries to reconnect to server which is
understartup 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
acceptconnections.  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.
 

Regards,
Amul Sul
Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Logging of PAM Authentication Failure
Next
From: Kevin Grittner
Date:
Subject: Re: counting algorithm for incremental matview maintenance