From: Chen, Yan-Jack (NSB - CN/Hangzhou) <yan-jack.chen@nokia-sbell.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: RE: PostgreSQL debug log doesn't record whole procedure(from receiving request to sending response)
Date: Tue, 16 Nov 2021 05:14:19 +0000
Message-ID: <a5d754c145e2443db972d9baa8558bbb@nokia-sbell.com> (raw)
In-Reply-To: <2122088.1636988967@sss.pgh.pa.us>
References: <6b903e4382a04e39bed5745d9915e932@nokia-sbell.com>
<2122088.1636988967@sss.pgh.pa.us>
"Tom Lane" <tgl@sss.pgh.pa.us> writes:
> 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?).
We have the same as your second suspicion. Delays in fsyncing WAL as the backend ceph cluster storage and we see there was significant latency increased during that time. Yes. the synchronous_commit is
on.
fsync | on | Forces synchronization of updates to disk.
synchronous_commit | on | Sets the current transaction's synchronization level.
> [ 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.
Actually, do not need to write log for every line code. The last debug log we can see is for CommitTransaction which state is INPROGRESS. But we can't see when CommitTransaction state is DONE/COMPLETE from the debug log which I think this kind of log is valuable which can help to identify where the delay comes, from server or client from the postgres server debug log only shall be enough without to monitoring and analyzing the TCP message.
[2701833-618d1b70.293a09-173273] 2021-11-13 22:25:58.051 GMT <169.254.0.21 UPDATE> DEBUG: 00000: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 23280/1/1
[2701833-618d1b70.293a09-173274] 2021-11-13 22:25:58.051 GMT <169.254.0.21 UPDATE> LOCATION: ShowTransactionStateRec, xact.c:5333
Best Regards
It always takes longer than you expect,
even when you take into account
----------------------------------------------------------------------------------------------
Yan-Jack Chen (陈雁)
Tel: +8613957141340
Addr: No.567 XinCheng Rd, Binjiang District, Hangzhou, China, 310053
-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: 2021年11月15日 23:09
To: Chen, Yan-Jack (NSB - CN/Hangzhou) <yan-jack.chen@nokia-sbell.com>
Cc: pgsql-general@postgresql.org
Subject: Re: PostgreSQL debug log doesn't record whole procedure(from receiving request to sending response)
"Chen, Yan-Jack (NSB - CN/Hangzhou)" <yan-jack.chen@nokia-sbell.com> writes:
> We recently encounter one issue about PostgreSQL ODBC client doesn¡¯t receive response from PostgreSQL server in time (client set 5 seconds timeout) occasionally (1 or 2 times per 24 hours). Both PostgreSQL and its client are deployed in VM against. It took us days to debug where cause the timeout. We enable PostgreSQL server debug log via below configuration.
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¡¯t really include the response message delay which may cause misleading why troubleshooting. It looks to me the debug log doesn¡¯t record the whole procedure. If there are some developer options include the missing part but we didn¡¯t 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: yan-jack.chen@nokia-sbell.com, tgl@sss.pgh.pa.us
Subject: Re: PostgreSQL debug log doesn't record whole procedure(from receiving request to sending response)
In-Reply-To: <a5d754c145e2443db972d9baa8558bbb@nokia-sbell.com>
References: <6b903e4382a04e39bed5745d9915e932@nokia-sbell.com> <2122088.1636988967@sss.pgh.pa.us> <a5d754c145e2443db972d9baa8558bbb@nokia-sbell.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox