Re: background sessions

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Borodin <amborodin(at)acm(dot)org>, amul sul <sulamul(at)gmail(dot)com>
Subject: Re: background sessions
Date: 2017-03-18 14:59:16
Message-ID: 31da1617-5d7a-b4a9-85cb-3ae7abdd95dd@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15/03/17 17:58, Robert Haas wrote:
> On Wed, Mar 15, 2017 at 6:43 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>> I don't understand - CHECK_FOR_INTERRUPTS called from executor implicitly.
>
> True. So there shouldn't be any problem here. I'm confused as can be
> about what you want changed.
>
> Some review of the patch itself:
>
> + pq_redirect_to_shm_mq(session->seg, session->command_qh);
> + pq_beginmessage(&msg, 'X');
> + pq_endmessage(&msg);
> + pq_stop_redirect_to_shm_mq();
>
> shm_redirect_to_shm_mq() wasn't really designed to be used this way;
> it's designed for use by the worker, not the process that launched it.
> If an error occurs while output is redirected, bad things will happen.
> I think it would be better to find a way of sending that message to
> the queue without doing this.

Couldn't we just create special version of pq_endmessage that sends to
shm_mq?

>
> Also, I suspect this is deadlock-prone. If we get stuck trying to
> send a message to the background session while the queue is full, and
> at the same time the session is stuck trying to send us a long error
> message, we will have an undetected deadlock. That's why
> pg_background() puts the string being passed to the worker into the
> DSM segment in its entirety, rather than sending it through a shm_mq.
>

Yeah I think this will need to use the nowait = true when sending to
shm_mq and chunk the message if necessary...

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-03-18 15:29:16 Re: createlang/droplang deprecated
Previous Message Magnus Hagander 2017-03-18 14:16:49 Re: createlang/droplang deprecated