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 1mmdc5-0003Xz-F1 for pgsql-general@arkaria.postgresql.org; Mon, 15 Nov 2021 15:09:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mmdc4-0006hp-FI for pgsql-general@arkaria.postgresql.org; Mon, 15 Nov 2021 15:09:40 +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 1mmdc4-0006hf-4P for pgsql-general@lists.postgresql.org; Mon, 15 Nov 2021 15:09:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmdc1-0003GR-UO for pgsql-general@postgresql.org; Mon, 15 Nov 2021 15:09:39 +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 1AFF9RYM2122089; Mon, 15 Nov 2021 10:09:29 -0500 From: Tom Lane To: "Chen, Yan-Jack (NSB - CN/Hangzhou)" cc: "pgsql-general@postgresql.org" Subject: Re: PostgreSQL debug log doesn't record whole procedure(from receiving request to sending response) In-reply-to: <6b903e4382a04e39bed5745d9915e932@nokia-sbell.com> References: <6b903e4382a04e39bed5745d9915e932@nokia-sbell.com> Comments: In-reply-to "Chen, Yan-Jack (NSB - CN/Hangzhou)" message dated "Mon, 15 Nov 2021 02:21:28 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2122087.1636988967.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 15 Nov 2021 10:09:27 -0500 Message-ID: <2122088.1636988967@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Chen, Yan-Jack (NSB - CN/Hangzhou)" write= s: > We recently encounter one issue about PostgreSQL ODBC client doesn=C2=A1= =C2=AFt receive response from PostgreSQL server in time (client set 5 seco= nds timeout) occasionally (1 or 2 times per 24 hours). Both PostgreSQL an= d its client are deployed in VM against. It took us days to debug where ca= use the timeout. We enable PostgreSQL server debug log via below configura= tion. We can see from this that the server spent 10 seconds in CommitTransaction, so the question is what took so long. I'd wonder first about end-of-transaction triggers (have you got foreign keys on that table? maybe an event trigger?), and then second about delays in writing/fsyncing WAL (what's the underlying storage? do you have synchronous_commit replication turned on?). > This mail is to ask why PostgreSQL debug log doesn=C2=A1=C2=AFt really i= nclude the response message delay which may cause misleading why troublesh= ooting. It looks to me the debug log doesn=C2=A1=C2=AFt record the whole p= rocedure. If there are some developer options include the missing part but= we didn=C2=A1=C2=AFt enable? [ shrug... ] Sure, we could put an elog(DEBUG) after every line of code in the server, and then high-level debugging logs would be even more impossibly voluminous than they are now. I'd say the existing logging gave you plenty of clue where to look. regards, tom lane