Skip to content

Commit

Permalink
*: fix goroutine leak in ddl intergration test (#30369)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao authored Dec 3, 2021
1 parent 891517f commit ac69c60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 13 additions & 2 deletions cmd/ddltest/ddl_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func createDDLSuite(t *testing.T) (s *ddlSuite) {
require.NoError(t, err)
ddl.RunWorker = false
session.ResetStoreForWithTiKVTest(s.store)
s.dom.Close()
require.NoError(t, s.store.Close())

s.store, err = store.New(fmt.Sprintf("tikv://%s%s", *etcd, *tikvPath))
require.NoError(t, err)
s.s, err = session.CreateSession(s.store)
require.NoError(t, err)
s.dom, err = session.BootstrapSession(s.store)
Expand Down Expand Up @@ -235,8 +240,14 @@ func (s *ddlSuite) stopServers() error {
defer s.m.Unlock()

for i := 0; i < len(s.procs); i++ {
if s.procs[i] != nil {
err := s.killServer(s.procs[i].Process)
if proc := s.procs[i]; proc != nil {
if proc.db != nil {
if err := proc.db.Close(); err != nil {
return err
}
}

err := s.killServer(proc.Process)
if err != nil {
return errors.Trace(err)
}
Expand Down
8 changes: 7 additions & 1 deletion cmd/ddltest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ func TestMain(m *testing.M) {
fmt.Fprint(os.Stderr, err.Error())
os.Exit(1)
}
goleak.VerifyTestMain(m)
opts := []goleak.Option{
goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
goleak.IgnoreTopFunction("net/http.(*persistConn).writeLoop"),
}
goleak.VerifyTestMain(m, opts...)
}

0 comments on commit ac69c60

Please sign in to comment.