pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
HandleParallelMessages contains CHECK_FOR_INTERRUPTS?
4+ messages / 2 participants
[nested] [flat]

* HandleParallelMessages contains CHECK_FOR_INTERRUPTS?
@ 2016-08-01 18:08  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2016-08-01 18:08 UTC (permalink / raw)
  To: pgsql-hackers

$SUBJECT seems like a pretty bad idea, because it implies a recursive
entry to ProcessInterrupts and thence to HandleParallelMessages itself.
By what reasoning is that call necessary where it's placed?

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: HandleParallelMessages contains CHECK_FOR_INTERRUPTS?
@ 2016-08-01 20:20  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Alvaro Herrera @ 2016-08-01 20:20 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers

Tom Lane wrote:
> $SUBJECT seems like a pretty bad idea, because it implies a recursive
> entry to ProcessInterrupts and thence to HandleParallelMessages itself.
> By what reasoning is that call necessary where it's placed?

I notice you just removed the CHECK_FOR_INTERRUPTS in
HandleParallelMessages().  Did you notice that HandleParallelMessages
calls shm_mq_receive(), which calls shm_mq_receive_bytes(), which
contains a CHECK_FOR_INTERRUPTS() call?

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: HandleParallelMessages contains CHECK_FOR_INTERRUPTS?
@ 2016-08-01 20:37  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2016-08-01 20:37 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-hackers

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> $SUBJECT seems like a pretty bad idea, because it implies a recursive
>> entry to ProcessInterrupts and thence to HandleParallelMessages itself.
>> By what reasoning is that call necessary where it's placed?

> I notice you just removed the CHECK_FOR_INTERRUPTS in
> HandleParallelMessages().  Did you notice that HandleParallelMessages
> calls shm_mq_receive(), which calls shm_mq_receive_bytes(), which
> contains a CHECK_FOR_INTERRUPTS() call?

I figured there were probably other cases of recursion; it's unlikely
we could prevent them altogether.  But a check in a function that's
called *only* from ProcessInterrupts seems pretty dubious.

I wonder whether we should make use of HOLD_INTERRUPTS/RESUME_INTERRUPTS
to avoid the recursion scenario here.  It's not really clear to me whether
this stack of function would behave sanely if it's invoked recursively
when the outer level is partway through reading a message.  At the very
least, it seems like there might be a risk for out-of-order message
processing (inner recursion reads and processes next message while outer
level has read but not yet processed previous message).

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: HandleParallelMessages contains CHECK_FOR_INTERRUPTS?
@ 2016-08-02 20:42  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2016-08-02 20:42 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-hackers

I wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
>> I notice you just removed the CHECK_FOR_INTERRUPTS in
>> HandleParallelMessages().  Did you notice that HandleParallelMessages
>> calls shm_mq_receive(), which calls shm_mq_receive_bytes(), which
>> contains a CHECK_FOR_INTERRUPTS() call?

After study, I believe that that CHECK_FOR_INTERRUPTS() is unreachable
given that HandleParallelMessages passes nowait = true.  But it's not
unlikely that future changes in shm_mq.c might introduce such calls that
are reachable.

> I wonder whether we should make use of HOLD_INTERRUPTS/RESUME_INTERRUPTS
> to avoid the recursion scenario here.

I concluded that that would be good future-proofing, whether or not it's
strictly necessary today, so I pushed it.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2016-08-02 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 18:08 HandleParallelMessages contains CHECK_FOR_INTERRUPTS? Tom Lane <tgl@sss.pgh.pa.us>
2016-08-01 20:20 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-08-01 20:37   ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-02 20:42     ` Tom Lane <tgl@sss.pgh.pa.us>

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