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 1jY2L7-0002bb-Gt for pgsql-general@arkaria.postgresql.org; Mon, 11 May 2020 06:55:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jY2L6-0002JZ-EQ for pgsql-general@arkaria.postgresql.org; Mon, 11 May 2020 06:55:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jY2L6-0002JS-6S for pgsql-general@lists.postgresql.org; Mon, 11 May 2020 06:55:00 +0000 Received: from smh-06.1blu.de ([178.254.0.206]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jY2L3-0000PM-H9 for pgsql-general@lists.postgresql.org; Mon, 11 May 2020 06:54:59 +0000 Received: from [172.16.29.5] (helo=sh4-5.1blu.de) by smh-06.1blu.de with esmtp (Exim 4.86_2) (envelope-from ) id 1jY2Kw-0005fw-8a for pgsql-general@lists.postgresql.org; Mon, 11 May 2020 08:54:52 +0200 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.90_1) (envelope-from ) id 1jY2Kw-0006TA-6i for pgsql-general@lists.postgresql.org; Mon, 11 May 2020 08:54:50 +0200 Date: Mon, 11 May 2020 08:54:50 +0200 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPARE sid_sisisinst FROM :select_anw;' Message-ID: <20200511065450.GA20181@sh4-5.1blu.de> Reply-To: Matthias Apitz References: <20200427122123.GA11416@sh4-5.1blu.de> <5198.1587991204@sss.pgh.pa.us> <20200427130618.GA24964@sh4-5.1blu.de> <20200427131955.GB24964@sh4-5.1blu.de> <20200428081018.GB4007@sh4-5.1blu.de> <20200510105226.GA14033@sh4-5.1blu.de> <9787.1589124821@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9787.1589124821@sss.pgh.pa.us> X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk El día Sonntag, Mai 10, 2020 a las 11:33:41 -0400, Tom Lane escribió: > Matthias Apitz writes: > > 1. In addition to the above code, can I get somehow the connecting client's PID? If > > Not in any portable way. If you believe that the offending client is on > the local system, you could try building something involving netstat, > lsof, etc. getpeereid() might be useful too. I launched a shell script to get some more information in this case: ... if (len < (int32) sizeof(ProtocolVersion) || len > MAX_STARTUP_PACKET_LENGTH) { int pid = getpid(); char cmd[80]; sprintf(cmd, "/home/sisis/guru/getClient.sh %d", pid); system(cmd); ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg("invalid length %d of startup packet", len))); return STATUS_ERROR; } ... The process with the PID in question is 'postmaster': PS: 14622 ? Ss 0:00 /usr/local/sisis-pap/pgsql/bin/postmaster -D /data/postgresql11/data lsof -P -p 14622 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME postmaste 14622 postgres cwd DIR 254,0 4096 5373968 /data/postgresql11/data postmaste 14622 postgres rtd DIR 254,0 4096 2 / postmaste 14622 postgres txt REG 254,0 9959488 5636120 /usr/local/sisis-pap/pgsql/bin/postgres postmaste 14622 postgres DEL REG 0,5 131559958 /dev/zero ... postmaste 14622 postgres 9u IPv4 131903453 0t0 TCP srap32dxr1.dev.oclc.org:5432->srap32dxr1.dev.oclc.org:44836 (ESTABLISHED) ... Interestingly, the other side of this connection of the port 5432 is not visible, i.e. a 'lsof -P | grep 5432' does not show it in this moment. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub