-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: migrate goroutine leak tests to goleak #27405
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,18 @@ | |
package executor | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/util/testbridge" | ||
"go.uber.org/goleak" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
testbridge.WorkaroundGoCheckFlags() | ||
os.Exit(m.Run()) | ||
opts := []goleak.Option{ | ||
goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"), | ||
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), | ||
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but still I don't know where this function comes from. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xhebox I found it comes from func initFileLog(cfg *FileLogConfig) (*lumberjack.Logger, error) {
return &lumberjack.Logger
}
func (l *Logger) millRun() {
for _ = range l.millCh {
// what am I going to do, log this?
_ = l.millRunOnce()
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. natefinch/lumberjack#56, It's a goroutine leak bug. |
||
} | ||
goleak.VerifyTestMain(m, opts...) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,11 @@ func (s *testTableSampleSuite) SetUpSuite(c *C) { | |
s.domain = d | ||
} | ||
|
||
func (s *testTableSampleSuite) TearDownSuite(c *C) { | ||
s.domain.Close() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not close domain and store generates 30+ goroutine leaks |
||
c.Assert(s.store.Close(), IsNil) | ||
} | ||
|
||
func (s *testTableSampleSuite) initSampleTest(c *C) *testkit.TestKit { | ||
atomic.StoreUint32(&ddl.EnableSplitTableRegion, 1) | ||
tk := testkit.NewTestKit(c, s.store) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be a buffer channel to unblock L8576, otherwise the anon goroutine blocked and leaks.