Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxVWi-0007Oy-EN for pgsql-bugs@arkaria.postgresql.org; Sun, 27 Jun 2021 14:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lxVWf-0006aj-6F for pgsql-bugs@arkaria.postgresql.org; Sun, 27 Jun 2021 14:12:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxVWe-0006ab-W4 for pgsql-bugs@lists.postgresql.org; Sun, 27 Jun 2021 14:12:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxVWa-000208-BS for pgsql-bugs@lists.postgresql.org; Sun, 27 Jun 2021 14:12:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15RECc8L3175545; Sun, 27 Jun 2021 10:12:38 -0400 From: Tom Lane To: Sudheer H R cc: pgsql-bugs@lists.postgresql.org Subject: Re: Socket (fd) to posters server getting closed. (libpq) In-reply-to: References: Comments: In-reply-to Sudheer H R message dated "Sun, 27 Jun 2021 19:32:06 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3175543.1624803158.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 27 Jun 2021 10:12:38 -0400 Message-ID: <3175544.1624803158@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sudheer H R 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=E2=80=A6 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 r= euse. > I notice that the retrieved connection has the socket fd closed, which l= eads to an error o the nature: could not receive data from server: Bad fi= le 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