From: | 蔡梦娟(玊于) <mengjuan(dot)cmj(at)alibaba-inc(dot)com> |
---|---|
To: | "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Queries that should be canceled will get stuck on secure_write function |
Date: | 2021-08-23 08:15:02 |
Message-ID: | adce2c09-3bfc-4666-997a-c21991cb1eb1.mengjuan.cmj@alibaba-inc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi, all
Recently, I got a problem that the startup process of standby is stuck and keeps in a waiting state. The backtrace of startup process shows that it is waiting for a backend process which conflicts with recovery processing to exit, the guc parameters max_standby_streaming_delay and max_standby_archive_delay are both set as 30 seconds, but it doesn't work. The backend process keeps alive, and the backtrace of this backend process show that it is waiting for the socket to be writeable in secure_write(). After further reading the code, I found that ProcessClientWriteInterrupt() in secure_write() only process interrupts when ProcDiePending is true, otherwise do nothing. However, snapshot conflicts with recovery will only set QueryCancelPending as true, so the response to the signal will de delayed indefinitely if the corresponding client is stuck, thus blocking the recovery process.
I want to know why the interrupt is only handled when ProcDiePending is true, I think query which is supposed to be canceled also should respond to the signal.
I also want to share a patch with you, I add a guc parameter max_standby_client_write_delay, if a query is supposed to be canceled, and the time delayed by a client exceeds max_standby_client_write_delay, then set ProcDiePending as true to avoid being delayed indefinitely, what do you think of it, hope to get your reply.
Thanks & Best Regard
Attachment | Content-Type | Size |
---|---|---|
0001-Set-max-client-write-delay-timeout-for-query-which-i.patch | application/octet-stream | 3.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Muhammad Usama | 2021-08-23 08:44:48 | Re: pg_dump handling of ALTER DEFAULT PRIVILEGES IN SCHEMA |
Previous Message | Amit Kapila | 2021-08-23 08:13:01 | Re: Separate out FileSet from SharedFileSet (was Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o) |