Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPAREsid_sisisinst FROM :select_anw;' - Mailing list pgsql-general

From Matthias Apitz
Subject Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPAREsid_sisisinst FROM :select_anw;'
Date
Msg-id 20200511065450.GA20181@sh4-5.1blu.de
Whole thread Raw
In response to Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPARE sid_sisisinst FROM :select_anw;'  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPARE sid_sisisinst FROM :select_anw;'
List pgsql-general
El día Sonntag, Mai 10, 2020 a las 11:33:41 -0400, Tom Lane escribió:

> Matthias Apitz <guru@unixarea.de> 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



pgsql-general by date:

Previous
From: Niels Jespersen
Date:
Subject: SV: what to log in csvlogs
Next
From: Michael Lewis
Date:
Subject: Re: Hash partitioning, what function is used to compute the hash?