Обсуждение: ECPG connection timeouts

Поиск
Список
Период
Сортировка

ECPG connection timeouts

От
"Edmund Bacon"
Дата:
Is it possible to control how long ECPG takes when trying to connect to
a database on a remote system (e.g. connect to tcp:postgres//remote/db)

In my environment it is quite possible that the link to the remote
system may be down, so I'd prefer not to have to force the end-user to
wait 3+ minutes while ECPG CONNECT times out.

I've tried using sig_action()/alarm() and also tried using
setjmp/longjmp with alarm, but to no avail.

Is there anything I can do within ECPG other than try a plain old
connect() to the remote system on port 5432 and not proceed with a ECPG
CONNECT if that fails?

Thanks,

Edmund Bacon


Re: ECPG connection timeouts

От
Michael Meskes
Дата:
On Tue, Mar 18, 2008 at 04:47:51PM -0600, Edmund Bacon wrote:
> Is it possible to control how long ECPG takes when trying to connect to
> a database on a remote system (e.g. connect to tcp:postgres//remote/db)

With ecpg calling libpq's connect functions you can just look here for possible options:

http://www.postgresql.org/docs/8.3/interactive/libpq-connect.html

You should use something like
tcp:postgresql://server/database?connect_timeout=14 as database name in
a connect statement. 

However, you will notice that this doesn't work as I just found that the
parser doesn't like the "=14" part. I will fix this in a minute.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!


Re: ECPG connection timeouts

От
meskes@postgresql.org
Дата:
[Answering my own email ...]

Zitat von Michael Meskes <meskes@postgresql.org>:
> However, you will notice that this doesn't work as I just found that the
> parser doesn't like the "=14" part. I will fix this in a minute.

Need to step backward a little bit. Fixing the parser was easy, but  
apparently PQsetdbLogin does not really set the option correctly.  
Before looking for the bug which might be a formatting problem in ecpg  
but appears to be a PQsetdbLogin limitation I think I better spend the  
time upgrading to use PQconnectDB instead.

BTW shouldn't setting PGOPTIONS (?) accordingly work too? Not sure  
after seeing PQsetdbLogin fail.

Michael