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

core/rawdb: close database in test to avoid goroutine leak #23287

Merged
merged 2 commits into from
Aug 8, 2021

Conversation

charlesxsh
Copy link
Contributor

In core/rawdb/accessors_chain_test.go:435

func TestAncientStorage(t *testing.T) {
}

db never close so goroutine created at core/rawdb/database.go:199 never return:

...
	if !frdb.readonly {
		frdb.wg.Add(1)
		go func() {
			frdb.freeze(db)    <==== not return until Close been call
			frdb.wg.Done()
		}()
	}
...

@@ -494,6 +494,9 @@ func TestAncientStorage(t *testing.T) {
if blob := ReadTdRLP(db, fakeHash, number); len(blob) != 0 {
t.Fatalf("invalid td returned")
}
if err := db.Close(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to use defer db.Close() near NewDatabaseWithFreezer

@fjl fjl changed the title add db close to avoid goroutine leak core/rawdb: close database in test to avoid goroutine leak Jul 29, 2021
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I fixed the defer!

@holiman holiman merged commit 9e59474 into ethereum:master Aug 8, 2021
@holiman holiman added this to the 1.10.7 milestone Aug 8, 2021
sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Aug 15, 2021
…23287)

* add db close to avoid goroutine leak

* core/rawdb: move close to defer

Co-authored-by: Martin Holst Swende <[email protected]>
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
…23287)

* add db close to avoid goroutine leak

* core/rawdb: move close to defer

Co-authored-by: Martin Holst Swende <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants