From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Alexander Kukushkin <cyberdemn(at)gmail(dot)com>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, Michael Paquier <michael(at)paquier(dot)xyz>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, "Leung, Anthony" <antholeu(at)amazon(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Allow non-superuser to cancel superuser tasks. |
Date: | 2024-11-26 17:27:33 |
Message-ID: | zioymjtx67mvph3ppxkfisumxlhol5vtgvi6xniwfecppiyt7j@3k4qd6eraxgb |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2024-11-22 20:44:34 -0600, Nathan Bossart wrote:
> On Fri, Nov 22, 2024 at 06:13:16PM -0500, Andres Freund wrote:
> >> - if (procStatus && procStatus->st_backendType == B_AUTOVAC_WORKER)
> >> + if (pgstat_get_backend_type(pid) == B_AUTOVAC_WORKER)
> >
> > Because we already mapped the pid to a ProcNumber, it'd be cheaper to access
> > the backend status via procnumber.
>
> D'oh, I missed that ProcNumber could be used as an index for the
> BackendStatusArray. Is the attached more like what you are imagining?
Yes.
I'd probably add two function header comments:
1) explicit caution that this is fetching information not from the snapshot
but "live" data
2) the return value might be out of date, that the procnumber needs to be
valid and that the caller is responsible for permission checking
I'd also add a comment do the code saying that it's fine to bypass the
changecount mechanism, because we're reading a single 4 byte integer.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-11-26 17:41:37 | Re: Doc: typo in config.sgml |
Previous Message | Tom Lane | 2024-11-26 17:26:51 | Re: Misleading "epoll_create1 failed: Too many open files" |