Re: Fix race in background worker termination for database

From: "Aya Iwata (Fujitsu)" <iwata(dot)aya(at)fujitsu(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Subject: Re: Fix race in background worker termination for database
Date: 2026-07-24 13:32:05
Message-ID: TYWPR01MB8901A6D3BAF3488F1FA7875EEACF2@TYWPR01MB8901.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Li-san

Thank you for sharing this fix patch.

>BackendPidGetProc() returns a PGPROC pointer after releasing
>ProcArrayLock, so the returned PGPROC is no longer protected. The ?
>corresponding entry in allProcs could be recycled after the function
>returns, in which case proc could refer to a different process when proc-
>>databaseId is accessed.

I'm not sure how long the PGPROC might be reused or modified after it is
retrieved, but it's true that the scenario you're describing could occur
depending on the timing.

I think this fix looks good. I would appreciate hearing what the other members think.

Regards,
Aya Iwata

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-07-24 13:38:05 Re: remove_useless_joins vs. bug #19560
Previous Message Hayato Kuroda (Fujitsu) 2026-07-24 13:31:35 RE: sequencesync worker race with REFRESH SEQUENCES