Skip to content

sync wrapper: Clear mutex poison and provide underlying mutex guar #160

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

Merged
merged 4 commits into from
Jul 12, 2024

Conversation

momobel
Copy link
Contributor

@momobel momobel commented Jun 19, 2024

Issue

Sqlite can return busy especially when multiple transactions are running concurrently. In async context with the Sync Wrapper, this will cause one client to get error (1) and panic within diesel causing the mutex to be poisoned and all subsequent clients panicking as a a result.

Cause

A busy timeout can be set and sqlite will pause waiting clients. This is set by the application but theoretically panics can still happen even with values in the order of seconds. Therefore an application could have a critical failure.

Resolution

This PR tries to recover from such situations. It includes a commit allow reproducing the issue that could be dropped if the PR is validated.

Would you have any other solutions to this issue? Or do you think this is the most we can do at the moment?

Notes

[1]
A panic is triggered because the statement iterator is NotStarted and doesn't contain the statement (that was consumed below).
Because an error is returned during the step.
I am not sure we can recover except by retrying until getting a non-busy result. This is still not ideal because it would be blocking or with arbitrary limits.

@weiznich
Copy link
Owner

Thanks for opening this PR. I'm currently away for holidays. I will have a look at this PR as after I'm back.

Copy link
Owner

@weiznich weiznich left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this PR. This change looks conceptually good, but I would like to see the "test" moved to the actual tests.

@weiznich weiznich force-pushed the sync_wrapper_clear_mutex_poison branch from 863ca64 to a5342a9 Compare July 12, 2024 10:01
@weiznich weiznich merged commit 444d45d into weiznich:main Jul 12, 2024
38 checks passed
@momobel
Copy link
Contributor Author

momobel commented Jul 15, 2024

Sorry, just came back to this topic and saw that you made comments. Thanks for handling them and merging!

@momobel momobel deleted the sync_wrapper_clear_mutex_poison branch July 15, 2024 06:47
@weiznich
Copy link
Owner

No worries, I'm just going through all the open PR's to finally prepare the next release.

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