Re: libpq: PQexec may block indefinitly

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Dmitry Samonenko <shreddingwork(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq: PQexec may block indefinitly
Date: 2014-05-29 04:59:08
Message-ID: CAA4eK1+M3vZjxXJPWnCc2tXAA8dDPLmdX1eL=xXoS8sW4JspiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 26, 2014 at 1:34 PM, Dmitry Samonenko <shreddingwork(at)gmail(dot)com>
wrote:
> 1. Connection to PSQL server is made without an option to specify
SO_RCVTIMEO and SO_SNDTIMEO. Why is that? Is setting socket timeouts
considered harmful?
> 2. PQexec ultimately leads to PQwait, which after some function calls
"lands" in pqSocketCheck and pqSocketPoll. These 2 functions have parameter
end_time. It is set (-1) for PQexec scenario, which leads to infinite poll
timeout in pqSocketPoll. Is it possible to implement configurable timeout
for PQexec calls? Is there some implemented features, which should be used
to handle situation like this?

Have you tried using Cancel functionality:
http://www.postgresql.org/docs/9.4/static/libpq-cancel.html

> Currently, I have changed Linux kernel tcp4 stack counters responsible
for retransmission, so OS actually closes socket after some period. This is
detected by pqSocketPoll's poll and libpq handles situation correctly -
error is reported to my application. But it's just a workaround.

There are certain tcp parameters which can be configured for connections.

tcp_keepalives_idle, tcp_keepalives_interval, tcp_keepalives_count

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2014-05-29 05:49:13 Re: pg_stat directory and pg_stat_statements
Previous Message Amit Kapila 2014-05-29 04:12:27 Re: Proposing pg_hibernate