Skip to content

Add get_pin_limit_hook#889

Closed
knizhnik wants to merge 2 commits intoREL_17_STABLE_neonfrom
pg17_prefetch_fix
Closed

Add get_pin_limit_hook#889
knizhnik wants to merge 2 commits intoREL_17_STABLE_neonfrom
pg17_prefetch_fix

Conversation

@knizhnik
Copy link

Define get_pin_limit_hook to prevent too small prefetch distance in case of large max_connections.

@hlinnaka hlinnaka force-pushed the REL_17_STABLE_neon branch 2 times, most recently from 43bf62f to 1c0ec25 Compare February 11, 2026 22:08
a-masterov and others added 2 commits February 12, 2026 10:02
Introduce probabilistic injection errors and SMGR API injection hook.

* Add a global counter `inside_smgr_api` (under `USE_INJECTION_POINTS`) in `postgres.c` and declare it in `postgres.h` so Neon’s injection framework can detect when execution is inside the SMGR API.
* In `ProcessInterrupts`, when injection points are enabled and `inside_smgr_api > 0`, trigger the `"SMGR_API"` injection point, allowing tests to simulate faults specifically while in SMGR-related code paths.
* Extend `InjectionPointCondition` with a `double prob` field representing a probability in [0, 1], and add `injection_error_prob` which behaves like `injection_error` but only raises an error according to this probability.
* Implement `injection_error_prob` to first check `injection_point_allowed`, then draw a random value using `rand()` and return early unless the draw is within the configured probability; otherwise it raises an error with `elog(ERROR, ...)`.
* Add `action2prob(const char *action, int pos)` to parse probability values encoded in the action name (e.g., `error-prob-0-01` → 0.01) by converting `-` to `.` and calling `strtod`, validating the result is in [0.0, 1.0], and erroring out on invalid values.
* Extend `injection_points_attach` to recognize actions starting with `error-prob-`, parse the probability into `condition.prob` via `action2prob`, and attach an injection point using `injection_error_prob` as the callback.

extern PGDLLEXPORT void injection_error(const char *name,
const void *private_data);
extern PGDLLEXPORT void injection_error_prob(const char *name,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just call this `injection_error_probability" so its clear its not "prob"lem. Do we have tests that utilize this or is it for manual testing. Good function to have though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it was not my commit.
It is from PR #878
Have no idea why it was included in this PR (looks like it is because of merge with vanilla).
Should I create new PR without this changes?
Or should we merge them?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets create a new PR so its clean

@knizhnik
Copy link
Author

Replaced with #892

@knizhnik knizhnik closed this Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants