Re: Injection point: fix race condition between attach and cleanup

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "'pgsql-hackers(at)lists(dot)postgresql(dot)org'" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>
Subject: Re: Injection point: fix race condition between attach and cleanup
Date: 2026-11-12 05:23:33
Message-ID: avVNVbUeLngeqiEM@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 11, 2026 at 12:26:41PM +0000, Hayato Kuroda (Fujitsu) wrote:
> Found issue
> ==========
> Injection points attached after injection_points_set_local() are removed via
> before_shmem_exit callback. This cleanup identifies an injection point only by name.
> If another backend detached the point and attached a new callback with the same
> name before the original backend exited, the cleanup could detach the new callback
> instead.

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.

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.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou 2026-11-12 05:36:14 Re: Crashes on a partition whose concurrent detach never finished
Previous Message Michael Paquier 2026-11-12 05:02:08 Re: Bug report and fix for: COMMIT/ROLLBACK AND CHAIN after an error drops the isolation level