Skip to content

Commit

Permalink
pgwire: fix race in TestConn
Browse files Browse the repository at this point in the history
A recent refactor introduced this race, since the context is used by
two testing goroutines.

Release note: None
  • Loading branch information
rafiss committed Jun 25, 2023
1 parent 7fd4c21 commit 87d41db
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/sql/pgwire/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ func TestConn(t *testing.T) {
log.Infof(context.Background(), "started listener on %s", serverAddr)

var g errgroup.Group
ctx := context.Background()
ctx, cancelConn := context.WithCancel(context.Background())
defer cancelConn()

var clientWG sync.WaitGroup
clientWG.Add(1)
Expand All @@ -103,8 +104,6 @@ func TestConn(t *testing.T) {
})

server := newTestServer()
ctx, cancelConn := context.WithCancel(ctx)
defer cancelConn()
// Wait for the client to connect and perform the handshake.
netConn, err := waitForClientConn(ln)
if err != nil {
Expand Down

0 comments on commit 87d41db

Please sign in to comment.