回复:Queries that should be canceled will get stuck on secure_write function

From: 蔡梦娟(玊于) <mengjuan(dot)cmj(at)alibaba-inc(dot)com>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>, "Fujii Masao" <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Andres Freund" <andres(at)anarazel(dot)de>
Subject: 回复:Queries that should be canceled will get stuck on secure_write function
Date: 2021-08-24 07:25:08
Message-ID: 6bac45f7-b546-44ac-81dd-40c05cdf7efd.mengjuan.cmj@alibaba-inc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Yes, pg_terminate_backend() can terminate the connection successfully in this case because ProcDiePending is set as true and ProcessClientWriteInterrupt() can handle it.

Queries those exceed standby delay limit can be terminated in this way, but what about other queries that should be canceled but get stuck on secure_write()? After all, there is currently no way to list all possible situations and then terminate these queries one by one.

------------------------------------------------------------------
发件人:Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
发送时间:2021年8月24日(星期二) 13:15
收件人:Robert Haas <robertmhaas(at)gmail(dot)com>; Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
抄 送:蔡梦娟(玊于) <mengjuan(dot)cmj(at)alibaba-inc(dot)com>; pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>; Andres Freund <andres(at)anarazel(dot)de>
主 题:Re: Queries that should be canceled will get stuck on secure_write function

On 2021/08/24 0:26, Alvaro Herrera wrote:
> Aren't we talking about query cancellations that occur in response to a
> standby delay limit? Those aren't in response to user action. What I
> mean is that if the standby delay limit is exceeded, then we send a
> query cancel; we expect the standby to cancel its query at that time and
> then the primary can move on. But if the standby doesn't react, then we
> can have it terminate its connection.

+1

On 2021/08/24 3:45, Robert Haas wrote:
> On Mon, Aug 23, 2021 at 11:26 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>> Aren't we talking about query cancellations that occur in response to a
>> standby delay limit? Those aren't in response to user action.
>
> Oh, you're right. But I guess a similar problem could also occur in
> response to pg_terminate_backend(), no?

There seems no problem in that case because pg_terminate_backend() causes
a backend to set ProcDiePending to true in die() signal hander and
ProcessClientWriteInterrupt() called by secure_write() handles ProcDiePending.
No?

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2021-08-24 07:46:37 Re: row filtering for logical replication
Previous Message Andrey Lepikhov 2021-08-24 07:21:48 Representation of SubPlan testexpr in EXPLAIN