Thread
Commits
-
Fix invalid value of pg_aios.pid, function pg_get_aios()
- 882bdcf9fd05 18.4 landed
- 93b76db0ace6 19 (unreleased) landed
-
Bug in pg_get_aios()
cca5507 <cca5507@qq.com> — 2026-03-23T06:23:04Z
Hi, If I understand correctly, we want to set nulls[0] to true if owner_pid equals to 0: ``` diff --git a/src/backend/storage/aio/aio_funcs.c b/src/backend/storage/aio/aio_funcs.c index 8997c762062..bcdd82318f7 100644 --- a/src/backend/storage/aio/aio_funcs.c +++ b/src/backend/storage/aio/aio_funcs.c @@ -149,7 +149,7 @@ retry: if (owner_pid != 0) values[0] = Int32GetDatum(owner_pid); else - nulls[0] = false; + nulls[0] = true; /* column: IO's id */ values[1] = Int32GetDatum(ioh_id); ``` -- Regards, ChangAo Chen -
Re: Bug in pg_get_aios()
Chao Li <li.evan.chao@gmail.com> — 2026-03-23T06:30:28Z
> On Mar 23, 2026, at 14:23, cca5507 <cca5507@qq.com> wrote: > > Hi, > > If I understand correctly, we want to set nulls[0] to true if owner_pid equals to 0: > > ``` > diff --git a/src/backend/storage/aio/aio_funcs.c b/src/backend/storage/aio/aio_funcs.c > index 8997c762062..bcdd82318f7 100644 > --- a/src/backend/storage/aio/aio_funcs.c > +++ b/src/backend/storage/aio/aio_funcs.c > @@ -149,7 +149,7 @@ retry: > if (owner_pid != 0) > values[0] = Int32GetDatum(owner_pid); > else > - nulls[0] = false; > + nulls[0] = true; > > /* column: IO's id */ > values[1] = Int32GetDatum(ioh_id); > ``` > > -- > Regards, > ChangAo Chen Indeed an obvious bug. If we looking downwards, there is a correct usage: ``` /* column: raw result (i.e. some form of syscall return value) */ if (start_state == PGAIO_HS_COMPLETED_IO || start_state == PGAIO_HS_COMPLETED_SHARED || start_state == PGAIO_HS_COMPLETED_LOCAL) values[9] = Int32GetDatum(ioh_copy.result); else nulls[9] = true; ``` Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
-
Re: Bug in pg_get_aios()
Michael Paquier <michael@paquier.xyz> — 2026-03-23T08:44:21Z
On Mon, Mar 23, 2026 at 02:30:28PM +0800, Chao Li wrote: >> On Mar 23, 2026, at 14:23, cca5507 <cca5507@qq.com> wrote: >> If I understand correctly, we want to set nulls[0] to true if owner_pid equals to 0: > > Indeed an obvious bug. Or the intention of the code could have been to allow a PID value of 0 to be exposed, but I don't really buy it. Will fix, thanks for the report. -- Michael
-
Re: Bug in pg_get_aios()
Andres Freund <andres@anarazel.de> — 2026-03-23T15:50:18Z
Hi, On March 23, 2026 4:44:21 AM EDT, Michael Paquier <michael@paquier.xyz> wrote: >On Mon, Mar 23, 2026 at 02:30:28PM +0800, Chao Li wrote: >>> On Mar 23, 2026, at 14:23, cca5507 <cca5507@qq.com> wrote: >>> If I understand correctly, we want to set nulls[0] to true if owner_pid equals to 0: >> >> Indeed an obvious bug. > >Or the intention of the code could have been to allow a PID value of 0 >to be exposed, but I don't really buy it. That certainly wasn't the intent :). I suspect this is unreachable, we wait for ios before exiting, but of course that doesn't excuse broken code. >Will fix, thanks for the report. Thanks! Andres -- Sent from my Android device with K-9 Mail. Please excuse my brevity.