From c04bfb1e374777d853e8abf16c8d26b887b31085 Mon Sep 17 00:00:00 2001 From: Dustin Ward <57266529+dustin-ward@users.noreply.github.com> Date: Thu, 10 Jun 2021 12:03:58 -0600 Subject: [PATCH 1/2] Prevent hang in Test/ClientUpdatesParamsAfterGoAway In cases where `t.Fatalf()` doesn't completely end the program, a `ctx.Err()` will cause the program to wait on a mutex indefinitely. Forcing the test to enter this specific `if` condition should reproduce the issue. Adding an unlock before reporting the error allows the program to fail the test as intended when a network error occurs. --- clientconn_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/clientconn_test.go b/clientconn_test.go index 6c61666b7ef..12804f4bb21 100644 --- a/clientconn_test.go +++ b/clientconn_test.go @@ -742,6 +742,7 @@ func (s) TestClientUpdatesParamsAfterGoAway(t *testing.T) { } if ctx.Err() != nil { // Timeout + cc.mu.RUnlock() t.Fatalf("cc.dopts.copts.Keepalive.Time = %v , want 20s", v) } cc.mu.RUnlock() From 42ff2ae051b6e8960f1734a83d6d96d97bcbcfb5 Mon Sep 17 00:00:00 2001 From: Dustin Ward <57266529+dustin-ward@users.noreply.github.com> Date: Thu, 10 Jun 2021 17:43:02 -0600 Subject: [PATCH 2/2] Move RUnlock outside of conditionals --- clientconn_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clientconn_test.go b/clientconn_test.go index 12804f4bb21..a50db9419c2 100644 --- a/clientconn_test.go +++ b/clientconn_test.go @@ -735,17 +735,15 @@ func (s) TestClientUpdatesParamsAfterGoAway(t *testing.T) { time.Sleep(10 * time.Millisecond) cc.mu.RLock() v := cc.mkp.Time + cc.mu.RUnlock() if v == 20*time.Second { // Success - cc.mu.RUnlock() return } if ctx.Err() != nil { // Timeout - cc.mu.RUnlock() t.Fatalf("cc.dopts.copts.Keepalive.Time = %v , want 20s", v) } - cc.mu.RUnlock() } }