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

found the goroutine leak in tikv client #20654

Closed
zier-one opened this issue Oct 27, 2020 · 5 comments · Fixed by #20808
Closed

found the goroutine leak in tikv client #20654

zier-one opened this issue Oct 27, 2020 · 5 comments · Fixed by #20808
Assignees
Labels
component/tikv severity/critical type/bug The issue is confirmed as a bug.
Milestone

Comments

@zier-one
Copy link
Contributor

zier-one commented Oct 27, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

func (s *serverOptionSuite) TestDDLPullerGoroutine(c *check.C) {
	go func() {
		err := http.ListenAndServe("localhost:8300", nil)
		log.Info("exit http server", zap.Error(err))
	}()

	_ = store.Register("tikv", tikv.Driver{})
	urlv, err := flags.NewURLsValue("http://127.0.0.1:2379")
	c.Assert(err, check.IsNil)

	tiPath := fmt.Sprintf("tikv://%s?disableGC=true", urlv.HostString())
	for {
		tiStore, err := store.New(tiPath)
		c.Assert(err, check.IsNil)
		time.Sleep(2 * time.Second)
		err = tiStore.Close()
		log.Info("one tick ", zap.Error(err))
		time.Sleep(2 * time.Second)
	}
}

run this code, and you can find the goroutine leak

2. What did you expect to see? (Required)

no goroutine leak

3. What did you see instead (Required)

goroutine leak

4. What is your TiDB version? (Required)

github.com/pingcap/tidb v1.1.0-beta.0.20200921080130-30cfb6af225c

@SunRunAway
Copy link
Contributor

@leoppro would you like file a PR?

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Nov 3, 2020

@tiancaiamao could help to take a look at this.

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Nov 3, 2020

@MyonKeminta will help to verify if the leak still exist in master and the release branch.

@MyonKeminta
Copy link
Contributor

The leak is found caused by not closing the etcd client in EtcdSafePointKV. The fix: #20808
It should exist in all release branches.

@scsldb scsldb added this to the v4.0.9 milestone Nov 4, 2020
@ti-srebot
Copy link
Contributor

ti-srebot commented Nov 5, 2020

Please edit this comment to complete the following information

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

The issue is caused by not closing the etcd client in EtcdSafePointKV after closing the tikvStore. Therefore every time open and close a tikv client, an etcd client will leak.

2. Symptom (optional)

goroutine leak after closing tikv client.

3. All Trigger Conditions (optional)

Closing a tikv client.

4. Workaround (optional)

-

5. Affected versions

[v2.0.0:v2.0.11], [v3.0.0:v3.0.19], [v3.1.0:v3.1.2], [v4.0.0:v4.0.8]

6. Fixed versions

v3.0.20, v4.0.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv severity/critical type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants