8000 Fix ZPool finalizers not running when resource acquisition fails or is interrupted by kyri-petrou · Pull Request #9163 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix ZPool finalizers not running when resource acquisition fails or is interrupted #9163

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 3 commits into from
Sep 3, 2024

Conversation

kyri-petrou
Copy link
Contributor
@kyri-petrou kyri-petrou commented Sep 3, 2024

/fixes #9152
/claim #9152

The previous behaviour would run the finalizers within an interruptible region in case of a failure. This means that in cases where the acquisition would be interrupted after some resource was first initialized (either due to interruption or failure) the finalizers wouldn't be run and the pool would contain invalid items.

/cc @987Nabil this should fix the flaky test in ZIO HTTP, but I'll test it more extensively once there's a snapshot version out

for {
latch <- Promise.make[Nothing, Unit]
latch2 <- Promise.make[Nothing, Unit]
incCounter = ZIO.acquireRelease(ZIO.unit)(_ => latch2.succeed(()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: We can't use a counter in this test because the interruption is "disconnected", so we need to use a promise and await it to check whether it's been completed

@kyri-petrou
Copy link
Contributor Author
kyri-petrou commented Sep 3, 2024

@jdegoes PS: I noticed some test flakiness; I looked into it and it doesn't seem to be related to the changes to the library code but to the addition of the nonFlaky annotation. I have a fix for it but I'll do it in a followup PR since it's unrelated to this one

@kyri-petrou kyri-petrou merged commit 3a3151f into zio:series/2.x Sep 3, 2024
18 checks passed
@kyri-petrou kyri-petrou deleted the fix-zpool-finalizers-issue branch September 3, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZPool leaks resources when acquisition is interrupted
2 participants
0