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

goroutine leak in new metrics loop() #31244

Open
demon-xxi opened this issue Feb 24, 2025 · 1 comment
Open

goroutine leak in new metrics loop() #31244

demon-xxi opened this issue Feb 24, 2025 · 1 comment
Assignees
Labels

Comments

@demon-xxi
Copy link

Using go-ethereum library as depednecy in my app for some types parsing. Not running geth rtc..
When upgrading from 1.14.11 to 1.15.2 the goleak started screaming.

Look like this PR #30814 introduced loop() goroutine that always stay active. there is no way to stop it. Also for the code that only refers dependency library for type parsing it's unclear why whole metrics system is initialized now.

System information

go-ethereum version: v1.15.2

Expected behaviour

metrics are not initialized and no extra goroutines spawned

Actual behaviour

meter.go loop() keeps running in goroutine()

Steps to reproduce the behaviour

package main

import (
	"testing"

	"github.com/ethereum/go-ethereum/rpc"
	"go.uber.org/goleak"
)

func TestLeak(t *testing.T) {
	defer goleak.VerifyNone(t)
	println(rpc.LatestBlockNumber)
}

Backtrace

main_test.go:18: found unexpected goroutines:
        [Goroutine 3 in state chan receive, with github.com/ethereum/go-ethereum/metrics.(*meterTicker).loop on top of the stack:
        github.com/ethereum/go-ethereum/metrics.(*meterTicker).loop(0x104783420)
                /Users/demon/.gvm/pkgsets/go1.22.10/global/pkg/mod/github.com/ethereum/go-ethereum@v1.15.2/metrics/meter.go:159 +0x50
        created by github.com/ethereum/go-ethereum/metrics.(*meterTicker).add in goroutine 1
                /Users/demon/.gvm/pkgsets/go1.22.10/global/pkg/mod/github.com/ethereum/go-ethereum@v1.15.2/metrics/meter.go:145 +0xc8

When submitting logs: please submit them as text and not screenshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment