Merged
Conversation
Merged
To reproduce the deadlock, put `runtime.Gosched()` right after `workersReady <- 1`. The `q.authCond.Signal()` is the being sent without any worker waiting at `q.authCond.Wait()`. Therefore all workers block at `q.authCond.Wait()` and the main goroutine blocks at `wg.Wait()` (deadlock). Use case 1, `q.transferables` is empty: `<-workersReady` is not (endlessly) blocking, because the additional `go func` closes the channel. The `q.authCond.Signal()` does not do anything. Use case 2, `q.transferables` is not empty: `<-workersReady` in combination with `q.authCond.L.Lock()` blocks until at least one worker is waiting (`q.authCond.Wait()`). Therefore the `q.authCond.Signal()` signals one of the goroutines to run. The size of the channel `workersReady` makes sure that every worker that passed `q.authCond.L.Lock()` before the main goroutine does not block at `workersReady <- 1`.
9ed77b6 to
ab77185
Compare
Contributor
Author
|
After the merge, all PR tests that timed out should be restarted. |
Contributor
|
Nice, that looks legit to me 👍 |
Contributor
Author
|
Just for reference, here is the commit causing the deadlock: 5619c5c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To reproduce the deadlock, put
runtime.Gosched()right afterworkersReady <- 1. Theq.authCond.Signal()is the being sent without any worker waiting atq.authCond.Wait(). Therefore all workers block atq.authCond.Wait()and the main goroutine blocks atwg.Wait()(deadlock).Use case 1
q.transferablesis empty:Use case 2
q.transferablesis not empty: