Re: [WIP] Patches to enable extraction state of query execution from external session

From: Maksim Milyutin <m(dot)milyutin(at)postgrespro(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [WIP] Patches to enable extraction state of query execution from external session
Date: 2016-09-02 16:07:25
Message-ID: 3db45fbd-a842-b985-9aad-3c4078355566@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

01.09.2016 18:58, Tom Lane пишет:
> Maksim Milyutin <m(dot)milyutin(at)postgrespro(dot)ru> writes:
>>> On Tue, Aug 30, 2016 at 9:34 AM, Maksim Milyutin
>>> <m(dot)milyutin(at)postgrespro(dot)ru <mailto:m(dot)milyutin(at)postgrespro(dot)ru>> wrote:
>>> Yes, but the problem is that nothing gives you the guarantee that at the
>>> moment you decide to handle the interrupt, the QueryDesc structures
>>> you're looking at are in a good shape for Explain* functions to run on
>>> them. Even if that appears to be the case in your testing now, there's
>>> no way to tell if that will be the case at any future point in time.
>
>> CHECK_FOR_INTERRUPTS are located in places where query state (QueryDesc
>> structure) is more or less consistent.
>
> Really? Even if that's 100% true today, which I wouldn't bet very much
> on, it seems like a really dangerous property to insist on system-wide.
> The only restriction we have ever placed on CHECK_FOR_INTERRUPTS is that
> it occur at places where it'd be safe to throw elog(ERROR), and in general
> we don't assume that the active query is still in a usable state after
> an error. What you propose would amount to a new restriction that nothing
> can ever call any nontrivial subroutine while the active query tree is
> less than fully valid (because the subroutine might contain a
> CHECK_FOR_INTERRUPTS somewhere). That sounds impractical and
> unenforceable.

Ok, thanks! I could propose a different approach: when
CHECK_FOR_INTERRUPTS occurs, set a hook to be executed by the following
ExecProcNode(). The hook is going to be provided by my extension. It is
expected to send current query state to some recipient backend (the one
who asked for it). I think the active query is consistent after any node
have worked off one or zero rows. After it has sent all necessary data,
the hook will disable itself.

--
Maksim Milyutin
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2016-09-02 16:08:02 Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
Previous Message Kevin Grittner 2016-09-02 16:04:20 Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)