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.