Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ethclient/simulated: add goroutine leak test #31033

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

jwasinger
Copy link
Contributor

@jwasinger jwasinger commented Jan 15, 2025

Adds a basic sanity test case to catch any go-routines leaked from instantiation/closing of a simulated backend (as reported in #31022)

@jwasinger jwasinger requested a review from fjl as a code owner January 15, 2025 08:31
@jwasinger jwasinger force-pushed the simulated-backend-gr-leak-check branch from f802e0e to fbd661b Compare January 15, 2025 09:20
@jwasinger jwasinger changed the title ethclient/simulated: add test case to ensure that instantiation of a simulated backend does not leak go-routines. ethclient/simulated: add test case to ensure that a simulated backend does not leak go-routines after being closed Jan 15, 2025
@jwasinger
Copy link
Contributor Author

Currently these are the leaked go-routines that do not have PRs open to fix them:

--- FAIL: TestCheckSimBackendGoroutineLeak (0.02s)
    backend_test.go:395: leaked goroutines:
        github.com/syndtr/goleveldb/leveldb.
        	/Users/jwasinger/go/pkg/mod/github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7/leveldb/db_state.go:110 +0xe4
        created by github.com/syndtr/goleveldb/leveldb.openDB in goroutine xxx
        	/Users/jwasinger/go/pkg/mod/github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7/leveldb/db.go:149 +0x3d0
        
        github.com/ethereum/go-ethereum/eth/filters.
        	/Users/jwasinger/projects/go-ethereum-master/eth/filters/api.go:93 +0x74
        created by github.com/ethereum/go-ethereum/eth/filters.NewFilterAPI in goroutine xxx
        	/Users/jwasinger/projects/go-ethereum-master/eth/filters/api.go:81 +0xe0

@jwasinger jwasinger force-pushed the simulated-backend-gr-leak-check branch 2 times, most recently from cd31eac to c50e6ba Compare January 20, 2025 10:46
@jwasinger jwasinger force-pushed the simulated-backend-gr-leak-check branch from 53787e3 to 79f067d Compare January 21, 2025 08:35
fjl pushed a commit that referenced this pull request Jan 21, 2025
)

Discovered from failing test introduced
#31033 . We should ensure
`timeoutLoop` terminates if the filter event system is terminated.
@jwasinger jwasinger force-pushed the simulated-backend-gr-leak-check branch from 79f067d to c7bdcca Compare January 21, 2025 12:32
@s1na
Copy link
Contributor

s1na commented Jan 21, 2025

Out of curiosity is there reason why you went for a custom solution rather than goleak which the OP used?

@jwasinger
Copy link
Contributor Author

@s1na I was under the impression that the library wasn't sufficient for the case here, but looking into the documentation further: it definitely is and we should use it to simplify this PR.

sebastianst pushed a commit to ethereum-optimism/op-geth that referenced this pull request Jan 23, 2025
…056)

Discovered from failing test introduced
ethereum/go-ethereum#31033 . We should ensure
`timeoutLoop` terminates if the filter event system is terminated.
@jwasinger jwasinger force-pushed the simulated-backend-gr-leak-check branch from 5de3b7c to 1e30cbb Compare January 27, 2025 13:20
@jwasinger jwasinger force-pushed the simulated-backend-gr-leak-check branch from 0b2ff28 to 5edadd8 Compare February 25, 2025 09:46
@fjl fjl changed the title ethclient/simulated: add test case to ensure that a simulated backend does not leak go-routines after being closed ethclient/simulated: add goroutine leak test Feb 25, 2025
@fjl fjl merged commit f688343 into ethereum:master Feb 25, 2025
3 of 4 checks passed
@fjl fjl added this to the 1.15.3 milestone Feb 25, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants