Re: Weird test mixup
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-03-15T07:39:12Z
Lists: pgsql-hackers
Attachments
- 0001-Introduce-runtime-conditions-in-module-injection_poi.patch (text/x-diff) patch 0001
- 0002-Restrict-GIN-test-with-injection-points-to-run-on-lo.patch (text/x-diff) patch 0002
On Thu, Mar 14, 2024 at 07:13:53PM -0400, Tom Lane wrote: > Michael Paquier <michael@paquier.xyz> writes: >> Or we could just disable runningcheck because of the concurrency >> requirement in this test. The test would still be able to run, just >> less times. > > No, actually we *must* mark all these tests NO_INSTALLCHECK if we > stick with the current definition of injection points. The point > of installcheck mode is that the tests are supposed to be safe to > run in a live installation. Side-effects occurring in other > databases are completely not OK. I really don't want to plug any runtime conditions into the backend APIs, because there can be so much more that can be done there than only restricting a callback to a database. I can imagine process type restrictions, process PID restrictions, etc. So this knowledge should stick into the test module itself, and be expanded there. That's easier ABI-wise, as well. > I can see that some tests would want to be able to inject code > cluster-wide, but I bet that's going to be a small minority. > I suggest that we invent a notion of "global" vs "local" > injection points, where a "local" one only fires in the DB it > was defined in. Then only tests that require a global injection > point need to be NO_INSTALLCHECK. Attached is a POC of what could be done. I have extended the module injection_points so as it is possible to register what I'm calling a "condition" in the module that can be defined with a new SQL function. The condition is stored in shared memory with the point name, then at runtime the conditions are cross-checked in the callbacks. With the interface of this patch, the condition should be registered *before* a point is attached, but this stuff could also be written so as injection_points_attach() takes an optional argument with a database name. Or this could use a different, new SQL function, say a injection_points_attach_local() that registers a condition with MyDatabaseId on top of attaching the point, making the whole happening while holding once the spinlock of the shmem state for the module. By the way, modules/gin/ was missing missing a detach, so the test was not repeatable with successive installchecks. Adding a pg_sleep of a few seconds after 'gin-leave-leaf-split-incomplete' is registered enlarges the window, and the patch avoids failures when running installcheck in parallel for modules/gin/ and something else using gin, like contrib/btree_gin/: while make USE_MODULE_DB=1 installcheck; do :; done 0001 is the condition facility for the module, 0002 is a fix for the GIN test. Thoughts are welcome. -- Michael
Commits
-
injection_points: Store runtime conditions in private area
- 267d41dc4f41 17.0 landed
-
Introduce private data area for injection points
- 33181b48fd0e 17.0 landed
-
injection_points: Fix incorrect spinlock acquisition
- 597f66942d0b 17.0 landed
-
Make GIN tests using injection points concurrent-safe
- 5105c9079681 17.0 landed
-
injection_points: Fix race condition with local injection point tests
- f4083c497510 17.0 landed
-
injection_points: Introduce runtime conditions
- f587338dec87 17.0 landed
-
Make GIN test using injection points repeatable
- 997db123c054 17.0 landed
-
Fix backstop in gin test if injection point is not reached
- d802ff06d021 17.0 landed
-
Try to unbreak injection-fault tests in the buildfarm
- 85f65d7a26fc 17.0 landed
-
Disable tests using injection points in installcheck
- e2e3b8ae9ed7 17.0 landed