Re: Hooks for session start and end, take two

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, legrand legrand <legrand_legrand(at)hotmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Hooks for session start and end, take two
Date: 2019-10-03 04:20:09
Message-ID: 20191003042009.GF1586@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 02, 2019 at 09:09:53PM -0700, Andres Freund wrote:
> On 2019-10-03 11:03:39 +0900, Michael Paquier wrote:
>> The idea here is to have a hook which can be triggered at the start of
>> a process which can be externally triggered, which I guess is normal
>> even for WAL senders not connected to a database.
>
> But what can you do in that situation? Without a database connection,
> for example, you better not consider inserting anything into a table.

Adding extra custom logging information, or plug that information
elsewhere than Postgres. I have use cases for that when it comes to
store external telemetry data or audit things for events happening
specifically in Postgres.

> I have *SERIOUS* problems with performing additional writing
> transactions in case of a FATAL. Something might have thrown that for a
> reason, and just carrying on executing an arbitrary amount of code, this
> might even involve triggers etc, imo seriously is not OK.

Well, hook authors can do a lot of stupid things.. Anyway it looks
that the end hook is out of scope as far as the discussion has gone
based on the lack of facility, and that there is still interest for
the start hook.

I am just attaching a separate patch which adds only the start hook.
The discussion could always respawn from that. This takes care of the
HBA configuration when testing on Windows, and the module is still
named "hooks" intentionally to avoid a future rename.
--
Michael

Attachment Content-Type Size
session-hook-v2.patch text/x-diff 9.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-10-03 04:35:43 Re: Hooks for session start and end, take two
Previous Message Andres Freund 2019-10-03 04:09:53 Re: Hooks for session start and end, take two