-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
headerdownload: fix OOM due to inifinitely growing children in link #12404
Merged
Conversation
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
taratorio
commented
Oct 21, 2024
@@ -535,8 +540,6 @@ func (hd *HeaderDownload) InsertHeader(hf FeedHeaderFunc, terminalTotalDifficult | |||
} | |||
if bad { | |||
// If the link or its parent is marked bad, throw it out | |||
hd.moveLinkToQueue(link, NoQueue) | |||
delete(hd.links, link.hash) |
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.
done already inside hd.removeUpwards(link)
taratorio
commented
Oct 21, 2024
hd.removeUpwards(link) | ||
if parentLink, ok := hd.links[link.header.ParentHash]; ok { | ||
parentLink.RemoveChild(link) | ||
} |
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.
done already inside hd.removeUpwards(link)
AskAlexSharov
approved these changes
Oct 22, 2024
AskAlexSharov
pushed a commit
that referenced
this pull request
Oct 22, 2024
yperbasis
pushed a commit
that referenced
this pull request
Oct 24, 2024
This was referenced Oct 25, 2024
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.
relates to #11387, #11473, #10734
tried to simulate the OOM using #11799
What I found was infinitely growing alloc of headers when receiving new header messages in sentry's
blockHeaders66
handler (check screenshot below).It looks like this is happening because in the case of a bad child header: we delete it from the
links
map, however its parent link still holds a reference to it so the deleted link & header never get gc-ed. Furthermore if new similar bad hashes arrive after deletion they get appended to their parent header's link and the children of that link can grow indefinitely (here). Ie confirmed with debug logs (note link at 13450415 has 140124 children):The solution for this is to remove the bad link from its parent child list here so that 1) it gets gc-ed and 2) the children list does not grow indefinitely.