Re: Add a permission check to pg_stat_get_backend_subxact()

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add a permission check to pg_stat_get_backend_subxact()
Date: 2026-09-24 00:39:08
Message-ID: CAGRkXqSNCCO3Msnw3isDsshw-DO4a9gXYJTmDqaG2LofN1vo5Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Bertrand,

> I wonder if we should pass the copied PID to
ProcNumberGetTransactionIds() and
> validate it under ProcArrayLock, following the same idea as
> pgstat_fetch_stat_backend_by_pid()?

Yes, done in v9-0002, a new patch. pgstat_read_current_status() passes the
PID it copied, and ProcNumberGetTransactionIds() reports nothing when the
PGPROC entry holds another PID. It changes an exported function, so I
would keep it for HEAD.

> I think it would make sense to add pid at the end in the backbranches (if
we
> back patch it), as suggested in [1].

0001 fixes a misreport in 18, so I think it should go there too. v9 puts
the PID at the end of PgStat_Backend, and 0003 puts the user ID after it,
so the existing offsets do not change.

0003 is v8-0002 with only that move.'

Thanks,
Shihao

Attachment Content-Type Size
v9-0002-Check-the-PID-when-reading-the-transaction-status.patch application/octet-stream 3.5 KB
v9-0003-Make-per-backend-statistics-functions-respect-sta.patch application/octet-stream 15.7 KB
v9-0001-Store-the-PID-of-a-backend-in-its-statistics-entr.patch application/octet-stream 3.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-09-24 00:50:20 Re: Proposal: expose heavyweight lock wait start time in pg_stat_activity
Previous Message Michael Paquier 2026-09-24 00:06:16 Re: [Patch] Fix pg_get_multixact_stats() over-reporting members on a hot standby