pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Socket (fd) to posters server getting closed. (libpq) 2+ messages / 2 participants [nested] [flat]
* Socket (fd) to posters server getting closed. (libpq) @ 2021-06-27 14:02 Sudheer H R <sudheer.hr@tekenlight.com> 0 siblings, 1 reply; 2+ messages in thread From: Sudheer H R @ 2021-06-27 14:02 UTC (permalink / raw) To: pgsql-bugs@lists.postgresql.org Hi, I am writing a piece of software to connect to the Postgres database in the asynchronous manner and have used PQconnectStartParams, PQsendPrepare, PQFlush , etc… in conjunction with libev. The established connection is used for a transaction, and then added to a pool of connections, and then subsequently retrieved from the pool for reuse. I notice that the retrieved connection has the socket fd closed, which leads to an error o the nature: could not receive data from server: Bad file descriptor While the client library (libpq) does not detect the closed socket (unix domain socket) and tries to communicate with the server and throws an error. Saw this communication trail on the subject https://www.postgresql.org/message-id/12708.1411394055@sss.pgh.pa.us <https://www.postgresql.org/message-id/12708.1411394055@sss.pgh.pa.us; where someone else has faced the same error while coding in python (I am using Lua for this purpose) I guess it becomes necessary to check for readiness of read and write of the fd returned by PQsocket before continuing to use it again. My concern is, this is happening unexpectedly and quite soon (after the connection is added to the pool in 1 or 2 seconds) I would like to know the cause of closure of the connection, if there is any and like to arrest it rather than having to reopen the connection again. Any feedback regarding this would be appreciated. Regards, Sudheer ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Socket (fd) to posters server getting closed. (libpq) @ 2021-06-27 14:12 Tom Lane <tgl@sss.pgh.pa.us> parent: Sudheer H R <sudheer.hr@tekenlight.com> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2021-06-27 14:12 UTC (permalink / raw) To: Sudheer H R <sudheer.hr@tekenlight.com>; +Cc: pgsql-bugs@lists.postgresql.org Sudheer H R <sudheer.hr@tekenlight.com> writes: > I am writing a piece of software to connect to the Postgres database in the asynchronous manner and have used PQconnectStartParams, PQsendPrepare, PQFlush , etc… in conjunction with libev. > The established connection is used for a transaction, and then added to a pool of connections, and then subsequently retrieved from the pool for reuse. > I notice that the retrieved connection has the socket fd closed, which leads to an error o the nature: could not receive data from server: Bad file descriptor libpq itself will assuredly never close a socket that's associated with an open connection. You need to look elsewhere for the cause. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-06-27 14:12 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-06-27 14:02 Socket (fd) to posters server getting closed. (libpq) Sudheer H R <sudheer.hr@tekenlight.com> 2021-06-27 14:12 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox