Skip to content

fix: goroutines leak when subscribe tm events#10013

Closed
Bacbia3696 wants to merge 1 commit intotendermint:mainfrom
Bacbia3696:main
Closed

fix: goroutines leak when subscribe tm events#10013
Bacbia3696 wants to merge 1 commit intotendermint:mainfrom
Bacbia3696:main

Conversation

@Bacbia3696
Copy link

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)

{ "jsonrpc": "2.0", "method": "subscribe", "id": 0, "params": { "query": "tm.event='NewBlock' AND tm.event='NewBlock' AND tm.event='NewBlock' AND tm.event='NewBlock'" } }`

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.

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale for use by stalebot label Mar 23, 2023
@github-actions github-actions bot closed this Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale for use by stalebot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant