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

ringhash: fix bug where ring hash can be stuck in transient failure despite having available endpoints #7364

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/testutils/blocking_context_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ func (h *Hold) Fail(err error) {
h.blockCh <- err
close(h.blockCh)
}

// IsStarted returns true if this hold has received a connection attempt.
func (h *Hold) IsStarted() bool {
select {
case <-h.waitCh:
return true
default:
return false
}
}
13 changes: 13 additions & 0 deletions internal/testutils/blocking_context_dialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ func (s) TestBlockingDialer_HoldWaitResume(t *testing.T) {
d := NewBlockingDialer()
h := d.Hold(lis.Addr().String())

if h.IsStarted() {
t.Fatalf("hold.IsStarted() = true, want false")
}

done := make(chan struct{})
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
Expand All @@ -69,13 +73,22 @@ func (s) TestBlockingDialer_HoldWaitResume(t *testing.T) {
t.Errorf("BlockingDialer.DialContext() got error: %v, want success", err)
return
}

if !h.IsStarted() {
t.Errorf("hold.IsStarted() = false, want true")
}
conn.Close()
}()

// This should block until the goroutine above is scheduled.
if !h.Wait(ctx) {
t.Fatalf("Timeout while waiting for a connection attempt to %q", h.addr)
}

if !h.IsStarted() {
t.Errorf("hold.IsStarted() = false, want true")
}

select {
case <-done:
t.Fatalf("Expected dialer to be blocked.")
Expand Down
Loading
Loading