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

Поиск
Список
Период
Сортировка
От maksim
Тема [WIP] Patches to enable extraction state of query execution from external session
Дата
Msg-id dbfb1a42-ee58-88fd-8d77-550498f52bc5@postgrespro.ru
обсуждение исходный текст
Ответы Re: [WIP] Patches to enable extraction state of query execution from external session  (Oleksandr Shulgin <oleksandr.shulgin@zalando.de>)
Re: [WIP] Patches to enable extraction state of query execution from external session  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers

Hi, hackers!

Now I complete extension that provides facility to see the current state of query execution working on external session in form of EXPLAIN ANALYZE output. This extension works on 9.5 version, for 9.6 and later it doesn't support detailed statistics for parallel nodes yet.

I want to present patches to the latest version of PostgreSQL core to enable this extension.


1. Patch that provides facility to send user signal to external backend (custom_signals.patch).

This patch transparently extends process signal interface to enable sending user defined signals (I call them - custom signals) and defining callbacks to them. Formally it will appear in following manner:

    /* Register custom signal and define signal callback */
    Reason = RegisterCustomProcSignalHandler(sighandler);

    void
    sighandler(void)
   {
       ...
   }

    /* On other session we can send process signal to the first backend */
   SendProcSignal(pid, Reason, backendId)

The InterruptPending flag is set under process signal handling and sighandler is called in CHECK_FOR_INTERRUPTS.
I use this patch to notice other backend to send its state to caller.

2. Patch that enables to interrupt the query executor (executor_hooks.patch).
This patch enables to hang up hooks on executor function of each node (ExecProcNode). I define hooks before any node execution and after execution.
I use this patch to add possibility of query tracing by emitted rows from any node. I interrupt query executor after any node delivers one or zero rows to upper node. And after execution of specific number trace steps I can get the query state of traceable backend which will be somewhat deterministic. I use this possibility for regression tests of my extension.

3. Patch that enables to output runtime explain statistics (runtime_explain.patch).
This patch extends the regular explain functionality. The problem is in the point that regular explain call makes result output after query execution performing InstrEndLoop on nodes where necessary. My patch introduces specific flag *runtime* that indicates whether we explain running query and does some insertions in source code dedicated to output the statistics of running query.
I want to notice that this patch is completed only for 9.5 postgres version. For later versions there is not implemented detailed statistics for parellel nodes. Now, I'm working at this feature.


That's all. CC welcome!

-- 
Maksim Milyutin
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Steele
Дата:
Сообщение: Re: Renaming of pg_xlog and pg_clog
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Renaming of pg_xlog and pg_clog