Re: Hooks for session start and end, take two

Поиск
Список
Период
Сортировка
От Mike Palmiotto
Тема Re: Hooks for session start and end, take two
Дата
Msg-id CAMN686FXCPBMi-Bj=b9py2XKaV=iZVUXcTrwZEFmPodOxxWWEg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Hooks for session start and end, take two  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On Thu, Oct 3, 2019 at 11:09 AM Andres Freund <andres@anarazel.de> wrote:
>
> <snip>
> I think what would need to be designed is something more like
> RegisterXactCallback():
>
> /*
>  *      start- and end-of-transaction callbacks for dynamically loaded modules
>  */
> typedef enum
> {
>         XACT_EVENT_COMMIT,
>         XACT_EVENT_PARALLEL_COMMIT,
>         XACT_EVENT_ABORT,
>         XACT_EVENT_PARALLEL_ABORT,
>         XACT_EVENT_PREPARE,
>         XACT_EVENT_PRE_COMMIT,
>         XACT_EVENT_PARALLEL_PRE_COMMIT,
>         XACT_EVENT_PRE_PREPARE
> } XactEvent;
>
> typedef void (*XactCallback) (XactEvent event, void *arg);
>
> extern void RegisterXactCallback(XactCallback callback, void *arg);
> extern void UnregisterXactCallback(XactCallback callback, void *arg);
>
>
> which would be called at various parts of a processes lifetime. Maybe
> something like:
>
> 1) shortly after process creation
> 2) shortly after shared memory attach
> 3) after database connection has been established
> 4) after database writes are possible (this excludes database-less walsenders)
> 5a) before closing database connection due to fatal error
>     (with a note saying that no writes are ever allowed)
> 5b) before closing database connection due to normal exit
>     (with a note saying that errors better be handled, and that no
>     transaction may escape)
> 6) before shared memory detach
> 7) before final exit

This suggestion really resonates with me, as I had considered
something similar in the process centralization patchset (CF entry
linked upthread and discussion here:
https://www.postgresql.org/message-id/flat/CAMN686FE0OdZKp9YPO=htC6LnA6aW4r-+jq=3Q5RAoFQgW8EtA@mail.gmail.com).
It would be possible to build such a mechanism into that existing
architecture rather easily. Has anyone had a chance to review that
work?

Thanks,
-- 
Mike Palmiotto
https://crunchydata.com



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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: Regarding extension
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: Transparent Data Encryption (TDE) and encrypted files