libpq: Which functions may hang due to network issues?

From: Daniel Frey <d(dot)frey(at)gmx(dot)de>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: libpq: Which functions may hang due to network issues?
Date: 2021-12-03 10:37:56
Message-ID: 2B29B70E-2A78-49D3-9861-5DD289DC30DD@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to know which functions of libpq may "hang", depending on network issues. For some functions is seems to be clear, as they only work locally, other functions are clearly documented to wait on some network interaction. But for some functions, it is unclear on whether they are guaranteed to work locally without any possibility to hang or not, e.g. PQfinish(), PQstatus(), PQtransactionStatus(), etc.

Is there a complete list of methods that might wait for network communication?

Some background: I'm writing a C++ wrapper for libpq <https://github.com/taocpp/taopq/> and our applications, which are going to use that library, should never hang, even when there is a network problem and network communication breaks down for a connection. For that reason I'm using asynchronous calls for libpq only and I use timeouts when polling on the socket/FD. When a timeout occurs, I need to handle the situation in a reasonable manner. In my case, I currently close the connection by calling PQfinish(). Also, later I might call PQstatus() or PQtransactionStatus() in order to decide whether a connection is still valid and should be returned to the connection pool or if it needs to be discarded.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sebastien Flaesch 2021-12-03 11:05:16 SUM() of INTERVAL type produces INTERVAL with no precision
Previous Message Dilip Kumar 2021-12-03 09:01:23 Re: Max connections reached without max connections reached