Parsed test spec with 3 sessions starting permutation: s3_prep s2_delete s1_scan s3_parked s3_vacuum s2_freed s2_insert s2_reused s2_wakeup s1_again s3_verify injection_points_attach ----------------------- (1 row) step s3_prep: VACUUM (FREEZE, ANALYZE) vcr; step s2_delete: DELETE FROM vcr WHERE k = 1; step s1_scan: SELECT count(*) AS rows_for_key_1 FROM vcr WHERE k = 1; step s3_parked: SELECT count(*) = 1 AS parked FROM pg_stat_activity WHERE wait_event_type = 'InjectionPoint' AND wait_event = 'lion-scan-chain-entered'; parked ------ t (1 row) step s3_vacuum: VACUUM vcr; step s2_freed: SELECT entries, deleted_pages > 0 AS chain_was_freed FROM lion_index_stats('vcr_k'); entries|chain_was_freed -------+--------------- 1|t (1 row) step s2_insert: INSERT INTO vcr SELECT i, 9 FROM generate_series(100001, 120000) i; step s2_reused: SELECT deleted_pages AS pages_left_free FROM lion_index_stats('vcr_k'); pages_left_free --------------- 1 (1 row) step s2_wakeup: /* * Detach first, so that nothing can park at the point again, then * release whoever is parked now. How MANY times the point is reached is * not fixed - the two-column driver runs more than one entry scan, and a * scan fires the point once per leaf it consumes an entry from - * but after this step nobody is waiting on it, which is all the * permutation needs. injection_points_wakeup() searches the WAITERS, so * it still works after the detach. */ SELECT injection_points_detach('lion-scan-chain-entered'); DO $$ DECLARE n int; zero int := 0; BEGIN FOR i IN 1 .. 6000 LOOP SELECT count(*) INTO n FROM pg_stat_activity WHERE wait_event = 'lion-scan-chain-entered'; IF n = 0 THEN zero := zero + 1; EXIT WHEN zero >= 10; ELSE zero := 0; /* * The waiter clears its slot itself once it notices the * counter, so it can be gone between the poll above and * this call; that is a success, not a failure. */ BEGIN PERFORM injection_points_wakeup('lion-scan-chain-entered'); EXCEPTION WHEN OTHERS THEN NULL; END; END IF; PERFORM pg_sleep(0.01); END LOOP; END $$; injection_points_detach ----------------------- (1 row) step s1_scan: <... completed> rows_for_key_1 -------------- 0 (1 row) step s1_again: SELECT count(*) AS rows_for_key_1 FROM vcr WHERE k = 1; SELECT count(*) AS rows_for_key_9 FROM vcr WHERE k = 9; rows_for_key_1 -------------- 0 (1 row) rows_for_key_9 -------------- 20000 (1 row) step s3_verify: SELECT lion_index_verify('vcr_k', true); lion_index_verify ----------------- (1 row)