forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd86d20f
committed
Add backend support for injection points
Injection points are a new facility that makes possible for developersto run custom code in pre-defined code paths. Its goal is to provideways to design and run advanced tests, for cases like:- Race conditions, where processes need to do actions in a controlledordered manner.- Forcing a state, like an ERROR, FATAL or even PANIC for OOM, to forcerecovery, etc.- Arbitrary sleeps.This implements some basics, and there are plans to extend it more inthe future depending on what's required. Hence, this commit adds a setof routines in the backend that allows developers to attach, detach andrun injection points:- A code path calling an injection point can be declared with the macroINJECTION_POINT(name).- InjectionPointAttach() and InjectionPointDetach() to respectivelyattach and detach a callback to/from an injection point. An injectionpoint name is registered in a shmem hash table with a library name and afunction name, which will be used to load the callback attached to aninjection point when its code path is run.Injection point names are just strings, so as an injection point can bedeclared and run by out-of-core extensions and modules, with callbacksdefined in external libraries.This facility is hidden behind a dedicated switch for ./configure andmeson, disabled by default.Note that backends use a local cache to store callbacks already loaded,cleaning up their cache if a callback has found to be removed on abest-effort basis. This could be refined further but any tests but whatwe have here was fine with the tests I've written while implementingthese backend APIs.Author: Michael Paquier, with doc suggestions from Ashutosh Bapat.Reviewed-by: Ashutosh Bapat, Nathan Bossart, Álvaro Herrera, DilipKumar, Amul Sul, Nazir Bilal YavuzDiscussion:https://postgr.es/m/ZTiV8tn_MIb_H2rE@paquier.xyz1 parentc03d91d commitd86d20f
File tree
17 files changed
+512
-0
lines changed- doc/src/sgml
- src
- backend
- storage
- ipc
- lmgr
- utils
- activity
- misc
- include
- utils
- makefiles
- tools/pgindent
17 files changed
+512
-0
lines changedLines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
759 | 759 |
| |
760 | 760 |
| |
761 | 761 |
| |
| 762 | + | |
762 | 763 |
| |
763 | 764 |
| |
764 | 765 |
| |
| |||
839 | 840 |
| |
840 | 841 |
| |
841 | 842 |
| |
| 843 | + | |
842 | 844 |
| |
843 | 845 |
| |
844 | 846 |
| |
| |||
1532 | 1534 |
| |
1533 | 1535 |
| |
1534 | 1536 |
| |
| 1537 | + | |
| 1538 | + | |
1535 | 1539 |
| |
1536 | 1540 |
| |
1537 | 1541 |
| |
| |||
3682 | 3686 |
| |
3683 | 3687 |
| |
3684 | 3688 |
| |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
3685 | 3719 |
| |
3686 | 3720 |
| |
3687 | 3721 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
250 | 250 |
| |
251 | 251 |
| |
252 | 252 |
| |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
253 | 260 |
| |
254 | 261 |
| |
255 | 262 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1656 | 1656 |
| |
1657 | 1657 |
| |
1658 | 1658 |
| |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
1659 | 1674 |
| |
1660 | 1675 |
| |
1661 | 1676 |
| |
| |||
3160 | 3175 |
| |
3161 | 3176 |
| |
3162 | 3177 |
| |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
3163 | 3193 |
| |
3164 | 3194 |
| |
3165 | 3195 |
| |
|
Lines changed: 69 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3599 | 3599 |
| |
3600 | 3600 |
| |
3601 | 3601 |
| |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
3602 | 3671 |
| |
3603 | 3672 |
| |
3604 | 3673 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
431 | 431 |
| |
432 | 432 |
| |
433 | 433 |
| |
| 434 | + | |
434 | 435 |
| |
435 | 436 |
| |
436 | 437 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 |
| |
47 | 50 |
| |
48 | 51 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
203 | 203 |
| |
204 | 204 |
| |
205 | 205 |
| |
| 206 | + | |
206 | 207 |
| |
207 | 208 |
| |
208 | 209 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| 54 | + | |
54 | 55 |
| |
55 | 56 |
| |
56 | 57 |
| |
| |||
151 | 152 |
| |
152 | 153 |
| |
153 | 154 |
| |
| 155 | + | |
154 | 156 |
| |
155 | 157 |
| |
156 | 158 |
| |
| |||
354 | 356 |
| |
355 | 357 |
| |
356 | 358 |
| |
| 359 | + | |
357 | 360 |
| |
358 | 361 |
| |
359 | 362 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
| 59 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
330 | 330 |
| |
331 | 331 |
| |
332 | 332 |
| |
| 333 | + | |
333 | 334 |
| |
334 | 335 |
| |
335 | 336 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
|
0 commit comments
Comments
(0)