Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement failure points #218

Merged
merged 4 commits into from
Nov 3, 2023
Merged

Conversation

medvied
Copy link
Contributor

@medvied medvied commented Oct 26, 2023

This patch adds API to trigger execution of C code from SQL to test corner cases.

test/sql/hnsw_failure_point.sql has an example of how to trigger a process crash using failure points and how to see that a space leak happens if a crash happens after a block is allocated, but before a record for the block is added to the index during blockmaps creation.

This patch adds API to trigger execution of C code from SQL to test
corner cases.

`test/sql/hnsw_failure_point.sql` has an example of how to trigger a
process crash using failure points and how to see that a space leak
happens if a crash happens after a block is allocated, but before a
record for the block is added to the index during blockmaps creation.
*state = (struct failure_point_state){
.enabled = true,
.func = func,
.name = name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do name and func live long enough for when it is used from state?

Both go out of scope and are freed as soon as the SQL function returns. It is allocated by the function context.

so, at that point the global state.name is dangling.
If this is the case, you should probably copy the strings. We do not care about performance for these, it should be fine

If you need the name after the

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Done.

I had a choice between using malloc() directly, using char func[0x100]; for the state->func and using a custom PostgreSQL allocator for this file. char func[0x100]; won.

@Ngalstyan4 Ngalstyan4 merged commit 09c3dfe into lanterndata:main Nov 3, 2023
@medvied medvied deleted the failure-point branch November 4, 2023 15:45
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.

2 participants