fix: goroutines leak when subscribe tm events#10013
Closed
Bacbia3696 wants to merge 1 commit intotendermint:mainfrom
Closed
fix: goroutines leak when subscribe tm events#10013Bacbia3696 wants to merge 1 commit intotendermint:mainfrom
Bacbia3696 wants to merge 1 commit intotendermint:mainfrom
Conversation
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When client submit a query event in tendermint websocket that parsed to more than 16 tokens, it will cause tendermint to leak goroutines -> crash due to out of memory.
For examples:
`❯ wscat --connect ws://0.0.0.0:26657/websocket
Connected (press CTRL+C to quit)
pprof:
goroutine profile: total 3227
3172 @ 0x104c60514 0x104c2a59c 0x104c2a148 0x10529c9d4 0x104c91974
0x10529c9d3 github.com/tendermint/tendermint/libs/pubsub/query.(*tokens32).Tokens.func1+0xa3
The reason is Tokens() return a channel, but consumer of that function might not consume all return value of, that will cause goroutine to hang forever
My quickfix is make channel size equal number token parsed by parser, so that channel will always be closed.