Add errdetail() with PID and UID about source of termination signal - Mailing list pgsql-hackers

From Jakub Wartak
Subject Add errdetail() with PID and UID about source of termination signal
Date
Msg-id CAKZiRmyrOWovZSdixpLd3PGMQXuQL_zw2Ght5XhHCkQ1uDsxjw@mail.gmail.com
Whole thread
Responses Re: Add errdetail() with PID and UID about source of termination signal
List pgsql-hackers
Hi all,

From time to time we have scenario where somebody has some backend killed by
some_script_somewhere(TM) in a multi-department company scenario and
to me it was
always unnecessary time intensive to identify the origin of the signal.

eBPF/bpftrace can be used to find the origin, but I think that PG could
simply log which PID/UID (e.g. root or pg-user) raised the signal. So Linux
has SA_SIGINFO, we could use that to provide mentioned things. As expected,
search of course returned that it was discussed earlier here [1] 11 years ago,
but there was no patch back then, so attached is an attempt to do just that.

No GUC, and yes it only displays it on Linux. I think FreeBSD also has
this, but I
haven't tried it there (or I haven't tried other OSes without it -
proper autoconf/meson
sa_sigaction SA_SIGINFO detection  is probably missing with proper
#ifdefs ), but I
would first like to learn if that would be a welcomed feature or not.

-J.

[1] - https://hackorum.dev/topics/32019

Attachment

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: DOCS - System Applications 'datadir' parameter
Next
From: Amit Kapila
Date:
Subject: Re: Skipping schema changes in publication