| From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alexander Lakhin <exclusion(at)gmail(dot)com> |
| Subject: | Re: Injection point: fix race condition between attach and cleanup |
| Date: | 2026-11-19 00:33:12 |
| Message-ID: | CAD21AoBuB++wONcWaW95CgKscXsf8YYVr1=LD73PA_wfPSQ=0A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Nov 13, 2026 at 1:43 AM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Hi Michael,
>
> > Yeah, sure. Or just make sure that the first backend has exited
> > before attaching something else to the same point. Or just use a
> > differently-named point for the second backend, in the same path.
> > There are a couple of options.
>
> You meant everything can be handled on the test code side, right? Per our finding,
> 010_index_concurrently_upsert can fail due to this issue, and alternative fix
> patch for it was to ensure background sessions were exit. See "nocfbot" patch in [1].
> Remained other patches tries to fix the root cause for future developers.
> Sawada-san suggested the approach in the original thread [2], he have not seen
> the implementation yet though.
>
> > FWIW, I've read your patch, and I am absolutely unconvinced about the
> > fact that we need to complicate the server side injpoint functionality
> > in core for only this purpose. Test facilities like this one should
> > remain simple in design, even if they require tweaks sometimes.
> > Complicating them would lead to bugs in the facility. I know that I
> > am pretty adamant about this part of the code, but injpoints are used
> > for many cases across the whole tree, and what you are doing is
> > changing one property for another, complicating the code even further,
> > while on it.
Agreed. I suggested the tracking idea in the original thread, but
having looked at the patch, it's more complex than I expected.
> Hmm, thank you for the feedback. My alternative idea was to match the MyProcPid
> and InjectionPointCondition::pid, but it was also complex. InjectionPointDetach()
> is implemented in the core, but the condition is controlled in the extension side
> thus it's opaque from the core.
>
> Do some others have simpler ideas? Otherwise, we might choose fixing the test code
> to prevent the future BF failure.
Alternative idea would be to pass an optional bool to
BackgroundPsql.quit so that it quits the session and waits for the
corresponding backend to exit too. I think that would be enough for
010_index_concurrently_upsert. It's close to the alternative patch
Kuroda-san posted, in a reusable form. We can use it also in
051_effective_wal_level.pl.
The same detach-and-attach race can happen in principle for isolation
tests too, if a spec leaves a local point to be cleaned up on exit
while another spec reuses the same name. But I don't think that needs
handling. Using distinct names (or detaching explicitly) avoids it,
and it doesn't seem worth special handling on the injection point
side.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joao Rito | 2026-11-19 00:45:20 | [PATCH] doc: Fix autovacuum_max_workers and autovacuum_worker_slots descriptions |
| Previous Message | Chao Li | 2026-11-19 00:24:15 | Re: Fix ISSN output truncation when the issue code is nonzero |