Re: Can can I make an injection point wait occur no more than once?

From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Can can I make an injection point wait occur no more than once?
Date: 2025-07-07 22:02:17
Message-ID: 20250707220217.48.nmisch@google.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2025-07-07 22:31:33 Re: Can can I make an injection point wait occur no more than once?
Previous Message Tom Lane 2025-07-07 21:38:29 Re: What is a typical precision of gettimeofday()?