forked from greenaddress/electrs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Threading-related fixes from upstream romanz/electrs
Changes were taken from the latest romanz/electrs rpc.rs implementation prior to the major refactoring in v0.9.0 that significantly diverged the codebases (https://github.com/romanz/electrs/blob/af6ff09a275ec12b6fd0d6a101637f4710902a3c/src/rpc.rs). The relevant changes include (not a complete list): romanz#284 romanz#233 romanz@a3bfdda romanz#195 romanz#523 (only post-v0.9 change, a very minor one) This fixes a memory leak that could be reproduced using the following script, which opens and closes 500k connections with a concurrency of 20: $ seq 1 500000 | xargs -I {} -n 1 -P 20 sh -c 'echo '\''{"id":{},"method":"server.version","params":[]}'\''| nc 127.0.0.1 50001 -v -N' Before the fixes, memory usage would continue to grow the more connections are made, to around 35MB for 500k connections. After the fixes, memory usage is steady at around 25MB and doesn't grow with more connections.
- Loading branch information
Showing
1 changed file
with
31 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
d257ca2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running BS's electrs behind a haproxy with tcp-checks every few seconds, so I have been suffering from electrs getting killed every several hours.:
My healthchecks behaviour is similar to your example with
nc
it just queries version. Every healthcheck there is a new tcp connection.^^ same as
htop thr
counter. And it grows.I've this patch applied seems running better, at least it survived overnight. Seems that patch make is better, but problem still persist as thr grows. It leaks it seems.
I have other nodes (mostly ethereum garbage) on that server
tcp-check
ed and only electrs increasing thr counter there.d257ca2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just hammered it with the netcat oneliner from your descriptoion, no thr increase, but it increases with haproxy's standard tcp-checks:
d257ca2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has been further investigating, the healthcheck service is using by default a single RST packet and for some reason electrs never close connection after it which results in increasing number of threads.