From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Chapman Flack <jcflack(at)acm(dot)org> |
Cc: | Sumanth Vishwaraj <sumanth(dot)vishwaraj(at)oracle(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Mahesh Rao <mahesh(dot)p(dot)rao(at)oracle(dot)com>, Nazia Zaidi <najiah(dot)abide(at)oracle(dot)com>, Jitesh Tiwari <jitesh(dot)tiwari(at)oracle(dot)com>, Nick Wagner <nick(dot)wagner(at)oracle(dot)com>, Scott Corbin <scott(dot)corbin(at)oracle(dot)com>, Mack Bell <mack(dot)bell(at)oracle(dot)com>, Avinash Dubey <avinash(dot)x(dot)dubey(at)oracle(dot)com> |
Subject: | Re: New feature request for adding session information to PostgreSQL transaction log |
Date: | 2025-01-21 18:45:34 |
Message-ID: | 3366825.1737485134@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Chapman Flack <jcflack(at)acm(dot)org> writes:
> I wonder how close one could get to the customer request (better
> forensics without having to build extra columns and triggers at the
> SQL level) with an extension and existing hooks.
An extension would be a great solution if we can make it work.
> I haven't used it, but isn't there now a facility for inserting
> additional custom records into the WAL? With ClientAuthentication_hook,
> could an extension add a record there for the creation of a new session,
> with timestamp and authenticated role oid?
I believe this is possible.
> Could an XactCallback be used to add a custom record at commit time
> identifying the responsible session? There would then be enough breadcrumbs
> to follow forensically from the commit to the session to the credentials.
I'm less sure about whether all the hooks exist today to do this, but
it seems like something we could allow if it's not there already.
However, I wonder whether this is sufficient. As you've sketched it,
it would permit tracing actions to sessions' login roles, but
individual actions might be taken under other roles. Does that need
to be captured? If so at what granularity? The maximalist approach
would probably be that every WAL record has to be labeled with
current_role, which would be a lot of overhead in the best case,
and still more if it has to be done via a separate WAL record.
> An added custom record at commit time likely costs more in space than
> extending the existing commit record with a session id, but seems like
> something an extension could do without changes in core.
I think this'd be an acceptable tradeoff if it only has to happen once
per commit. Not sure if that answers the request though.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Artem Gavrilov | 2025-01-21 18:47:37 | Re: [PATCH] Optionally record Plan IDs to track plan changes for a query |
Previous Message | Masahiko Sawada | 2025-01-21 18:36:11 | Re: Skip collecting decoded changes of already-aborted transactions |