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 1jXjZa-0005QD-Bj for pgsql-general@arkaria.postgresql.org; Sun, 10 May 2020 10:52:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jXjZX-0000tg-OG for pgsql-general@arkaria.postgresql.org; Sun, 10 May 2020 10:52:39 +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 1jXjZX-0000tZ-GK for pgsql-general@lists.postgresql.org; Sun, 10 May 2020 10:52:39 +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 1jXjZQ-0006Yo-8B for pgsql-general@lists.postgresql.org; Sun, 10 May 2020 10:52:38 +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 1jXjZL-0007m9-1j for pgsql-general@lists.postgresql.org; Sun, 10 May 2020 12:52:27 +0200 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.90_1) (envelope-from ) id 1jXjZK-0004y2-WF for pgsql-general@lists.postgresql.org; Sun, 10 May 2020 12:52:27 +0200 Date: Sun, 10 May 2020 12:52:26 +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: <20200510105226.GA14033@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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200428081018.GB4007@sh4-5.1blu.de> 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 Dienstag, April 28, 2020 a las 10:10:18 +0200, Matthias Apitz escribió: > > I've added the proposed log line to the server code in src/backend/libpq/pqcomm.c > and restarted the server with this. In the log file /data/postgresql11/data/serverlog > are other messages about length of packages, like: > > 2020-04-28 09:49:49.877 CEST [16229] LOG: invalid length of startup packet > 2020-04-28 09:49:50.117 CEST [16231] LOG: invalid length of startup packet > > They're coming from: > > grep 'invalid length of startup packet' src/backend/*/*.c > src/backend/postmaster/postmaster.c: errmsg("invalid length of startup packet"))); > > I will change the code there to to get the 'len' printed with the > message > > ... > if (len < (int32) sizeof(ProtocolVersion) || > len > MAX_STARTUP_PACKET_LENGTH) > { > ereport(COMMERROR, > (errcode(ERRCODE_PROTOCOL_VIOLATION), > errmsg("invalid length %d of startup packet", len))); > return STATUS_ERROR; > } I'm still trying to catch from where (i.e. from which client connection) the above message are originated. Over the actual weeken(!), I see the following picture: # egrep 'bogus|incomplete message from|invalid length' /data/postgresql11/data/serverlog ... 2020-05-09 05:35:20.124 CEST [6905] LOG: invalid length 33554940 of startup packet 2020-05-09 05:35:20.368 CEST [6907] LOG: invalid length 33554940 of startup packet 2020-05-09 05:38:14.381 CEST [7186] LOG: invalid length 33554940 of startup packet 2020-05-09 05:38:14.669 CEST [7246] LOG: invalid length 33554940 of startup packet 2020-05-10 05:34:56.716 CEST [13241] LOG: invalid length 33554940 of startup packet 2020-05-10 05:34:56.942 CEST [13243] LOG: invalid length 33554940 of startup packet 2020-05-10 05:37:46.599 CEST [13921] LOG: invalid length 33554940 of startup packet 2020-05-10 05:37:49.577 CEST [14017] LOG: invalid length 33554940 of startup packet i.e. the messages only appear short after 5:3x am; this is exactly the time when (based on cronjobs) our software is deployed to this server and all servers (the clients for PostgreSQL) are started. Following questions: 1. In addition to the above code, can I get somehow the connecting client's PID? If so, I could get from its PID its command line from the /proc file system. This would help to instrument the client side with logging. There are some hundred clients of different server types booting up at this time frame after the deployment. 2. Can I get something out of the buffer of the startup packet? For example, with adding to the above change something like: { char buf[1024+1]; memset (buf, 0, sizeof(buf)); pq_getbytes(buf, 1024); buf[1024] = '\0'; ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg("first 1024 bytes of startup packet [%s]", buf))); } Thanks matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub