-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Mutex does not release lock if interrupted during .lock() #1898
Comments
I guess this is caused by https://github.com/tokio-rs/tokio/blob/master/tokio/src/sync/mutex.rs#L91 where the semaphore |
bikeshedder
added a commit
to bikeshedder/tokio
that referenced
this issue
Dec 5, 2019
bikeshedder
added a commit
to bikeshedder/tokio
that referenced
this issue
Dec 5, 2019
bikeshedder
added a commit
to bikeshedder/tokio
that referenced
this issue
Dec 5, 2019
Semaphore::release() must also be called when it is in the waiting state.
bikeshedder
added a commit
to bikeshedder/tokio
that referenced
this issue
Dec 5, 2019
bikeshedder
added a commit
to bikeshedder/tokio
that referenced
this issue
Dec 5, 2019
Semaphore::release() must also be called when it is in the waiting state.
bikeshedder
added a commit
to bikeshedder/tokio
that referenced
this issue
Dec 5, 2019
Permit::release() must also be called when it is in the waiting state.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
Platform
Description
I tried writing a hyper based HTTP service that uses a
Mutex
inside a service method. When benchmarking the service I noticed some deadlocks where the application would hang forever waiting for the mutex to be released.Reproduction
I have prepared a minimal reproduction example using the current master branch of
hyper
,tokio
and nothing else. I usedinterval.tick()
to fake external service calls (e.g. database access) so the executor gets a chance to interrupt the service function and accept requests in parallel:https://github.com/bikeshedder/hyper-fail
cargo run --release
bash benchmark.sh
# this should workbash benchmark.sh
# this should fail (if not, repeat a few times)Output on my machine:
Analysis
I tried adding output before and after the
counter.lock()
call and noticed that after running the benchmark the numbers don't add up. This all makes sense becausewrk
does not wait for requests to be finished but terminates the connections.hyper
stops executing the service future if a client terminates the connection. It seams that interrupting a future that is currently callingMutex::lock()
and dropping it can cause the mutex to never unlock again.The text was updated successfully, but these errors were encountered: