Re: Can can I make an injection point wait occur no more than once? - Mailing list pgsql-hackers

From Noah Misch
Subject Re: Can can I make an injection point wait occur no more than once?
Date
Msg-id 20250707220217.48.nmisch@google.com
Whole thread Raw
In response to Can can I make an injection point wait occur no more than once?  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: Can can I make an injection point wait occur no more than once?
List pgsql-hackers
On Mon, Jul 07, 2025 at 05:31:30PM -0400, Peter Geoghegan wrote:
> I have successfully simulated "wait no more than once" by adding C
> code to nbtree that looks like this:
> 
>             if (likely(!P_ISDELETED(opaque) &&
>                        opaque->btpo_next == lastcurrblkno))
>             {
>                 /* Found desired page, return it */
> #ifdef USE_INJECTION_POINTS
>                 if (IS_INJECTION_POINT_ATTACHED("lock-and-validate-left"))
>                 {
>                     InjectionPointDetach("lock-and-validate-left");
>                 }
> #endif
> 
> But that's pretty ugly and non-modular. There are multiple return
> paths within _bt_lock_and_validate_left, and I'd probably need to
> cover them all with similar code. That seems borderline unacceptable.
> 
> It would be far preferable if I could just use some built-in way of
> waiting exactly once, that can be used directly from SQL, through the
> injection_points extension. That would allow me to write the isolation
> test without having to add any code to nbtsearch.c that knows all
> about the requirements of one particular isolation test.

In your test, just detach the injection point while the backend under test is
waiting at the injection point.  All of
src/test/modules/injection_points/specs/*.spec use that technique.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: What is a typical precision of gettimeofday()?
Next
From: Peter Geoghegan
Date:
Subject: Re: Can can I make an injection point wait occur no more than once?