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

2021-09-09 Thread Robert Haas
On Fri, Aug 27, 2021 at 4:10 PM Andres Freund wrote: > On Fri, Aug 27, 2021, at 13:07, Robert Haas wrote: > > On Fri, Aug 27, 2021 at 3:24 PM Andres Freund wrote: > > > I wonder if we could improve the situation somewhat by using the > > > non-blocking > > > pqcomm functions in a few select plac

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

2021-08-27 Thread Andres Freund
Hi, On Fri, Aug 27, 2021, at 13:07, Robert Haas wrote: > On Fri, Aug 27, 2021 at 3:24 PM Andres Freund wrote: > > I wonder if we could improve the situation somewhat by using the > > non-blocking > > pqcomm functions in a few select places. E.g. if elog.c's > > send_message_to_frontend() sent it

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

2021-08-27 Thread Robert Haas
On Fri, Aug 27, 2021 at 3:24 PM Andres Freund wrote: > I wonder if we could improve the situation somewhat by using the non-blocking > pqcomm functions in a few select places. E.g. if elog.c's > send_message_to_frontend() sent its message via a new pq_endmessage_noblock() > (which'd use the existi

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

2021-08-27 Thread Andres Freund
Hi, On 2021-08-27 08:27:38 -0400, Robert Haas wrote: > On Tue, Aug 24, 2021 at 9:58 PM Fujii Masao > wrote: > > to report an error to a client, and then calls AbortCurrentTransaction() > > to abort the transaction. If secure_write() called by EmitErrorReport() > > gets stuck, a backend gets stuc

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

2021-08-27 Thread Andres Freund
Hi, On 2021-08-23 10:13:03 -0400, Robert Haas wrote: > On Mon, Aug 23, 2021 at 4:15 AM 蔡梦娟(玊于) wrote: > > 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. > > Well, if we're h

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

2021-08-27 Thread Robert Haas
On Tue, Aug 24, 2021 at 9:58 PM Fujii Masao wrote: > I was thinking that it's valid even if secure_write() doesn't react to > pg_cancel_backend() because it's basically called outside transaction block, > i.e., there is no longer transaction to cancel in that case. But there can be > some cases wh

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

2021-08-24 Thread Fujii Masao
On 2021/08/25 2:30, Robert Haas wrote: Hmm, maybe you're right. What about pg_cancel_backend()? I was thinking that it's valid even if secure_write() doesn't react to pg_cancel_backend() because it's basically called outside transaction block, i.e., there is no longer transaction to cancel i

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

2021-08-24 Thread Robert Haas
On Tue, Aug 24, 2021 at 1:15 AM Fujii Masao wrote: > > 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() si

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

2021-08-23 Thread Fujii Masao
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 can

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

2021-08-23 Thread Robert Haas
On Mon, Aug 23, 2021 at 11:26 AM 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. Oh, you're right. But I guess a similar problem could also occur in response to pg_terminate_backend(),

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

2021-08-23 Thread Alvaro Herrera
On 2021-Aug-23, Robert Haas wrote: > On Mon, Aug 23, 2021 at 10:45 AM Alvaro Herrera > wrote: > > Do we actually need new GUCs, though? I think we should never let an > > unresponsive client dictate what the server does, because that opens the > > door for uncooperative or malicious clients to

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

2021-08-23 Thread Robert Haas
On Mon, Aug 23, 2021 at 10:45 AM Alvaro Herrera wrote: > Do we actually need new GUCs, though? I think we should never let an > unresponsive client dictate what the server does, because that opens the > door for uncooperative or malicious clients to wreak serious havoc. I > think the implementat

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

2021-08-23 Thread Alvaro Herrera
On 2021-Aug-23, Robert Haas wrote: > On Mon, Aug 23, 2021 at 4:15 AM 蔡梦娟(玊于) wrote: > > 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. Yeah, I agree. > Well, if we're halfway

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

2021-08-23 Thread Robert Haas
On Mon, Aug 23, 2021 at 4:15 AM 蔡梦娟(玊于) wrote: > 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. Well, if we're halfway through sending a message to the client and we abort the wr