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 1lxVN6-0007Ap-5l for pgsql-bugs@arkaria.postgresql.org; Sun, 27 Jun 2021 14:02:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lxVMZ-0004Sv-Ha for pgsql-bugs@arkaria.postgresql.org; Sun, 27 Jun 2021 14:02:19 +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 1lxVMZ-0004Sm-8F for pgsql-bugs@lists.postgresql.org; Sun, 27 Jun 2021 14:02:19 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lxVMU-0001vv-UU for pgsql-bugs@lists.postgresql.org; Sun, 27 Jun 2021 14:02:18 +0000 Received: by mail-pg1-x52e.google.com with SMTP id h4so12951628pgp.5 for ; Sun, 27 Jun 2021 07:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tekenlight.com; s=google; h=from:mime-version:subject:message-id:date:to; bh=zkqBor3d6OCUuWFsNiUeF2+kDS/n429kkIyYAtK8xgM=; b=JywCXCl9Yy4S7F/vO7zwep0TTK3MHy7CwFAs3+spqPLMbwc/6obf+7zPg7rXLPfP4l x5XK7W/zyJ28tHyZIJySCJiHUOTBGodYP9idWmqOV9eXirL+7uSZ1Npz5zf/EM9vhseP lDXoSOJtfHGKw5ieZnJjAHLxxvRUk9HQqvhQWwxVOh1lL01tbnXT1Y4Qt6GjAqCHd69y 5KsAoYotRz6LtYjqIrbEGKXP14Jf2g/KFmkhmZKY0ofERbTdF7lGGrY4GvMB+KO8GUO5 GBLXdXiEqs1zsp2RJ9ZufQvSaqJAlzeywIwHD4Li51zfFLLiXR5rAN8Bzn+vRmGEF4Up b8TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=zkqBor3d6OCUuWFsNiUeF2+kDS/n429kkIyYAtK8xgM=; b=suHPnJAoNADg2bFojh6YWPQIsi8+1pxREIiHX0UVYji2drkVauP3FOCj4q6IYJxcFW 3alvNK5DNR17HRj2fLc8aN+q/Xx6UvVQrXO6BqA0Xaqp0goxXlRWgJ6xAea8s7VsaHu0 qEBDhLPO5Y4EaF+GnUzPEAsVRy93MSunGSBOpWEXVmDAU6W0VM03kz1bSUG7amEai+X/ hzeuk7nKSjrFs9qk9fzL7EXn5Ev+A0J0EaVEZCzqjmLXQbDkxWRFiwwythpuA9R+gcyp NtkYPqzPFsLOcv43yNzWf5f3svVc9EeEmCuTPEYn/jz5eJR1UorL18ehikCxzAkq3ZST w+Ig== X-Gm-Message-State: AOAM532ijRyTlMgTFwgqF42rhjXRWhv/HhES632oQWuEjQ57DaOpde+d JcXDvQ6e8MTyzp24Lwlg3Eoae7rw6aV4Gw== X-Google-Smtp-Source: ABdhPJxfWra4b8b1G+iqc/jEY8o9eEt+Gjvc/iNPSiQTCob7+WHPqa3DGtahdcyU3FI8zgiGltNnvQ== X-Received: by 2002:a65:4c4f:: with SMTP id l15mr1284958pgr.256.1624802532312; Sun, 27 Jun 2021 07:02:12 -0700 (PDT) Received: from smtpclient.apple ([136.185.153.148]) by smtp.gmail.com with ESMTPSA id w15sm16842873pjg.32.2021.06.27.07.02.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Jun 2021 07:02:12 -0700 (PDT) From: Sudheer H R Content-Type: multipart/alternative; boundary="Apple-Mail=_8A959185-37D4-4F1B-8F90-BAE695D3BCBE" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Socket (fd) to posters server getting closed. (libpq) Message-Id: Date: Sun, 27 Jun 2021 19:32:06 +0530 To: pgsql-bugs@lists.postgresql.org X-Mailer: Apple Mail (2.3654.100.0.2.22) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_8A959185-37D4-4F1B-8F90-BAE695D3BCBE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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=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 = 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 = = 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 --Apple-Mail=_8A959185-37D4-4F1B-8F90-BAE695D3BCBE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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=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 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 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

= --Apple-Mail=_8A959185-37D4-4F1B-8F90-BAE695D3BCBE--