Skip to content
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

Accounts index updates, remove pubkey when dead account #7408

Merged
merged 1 commit into from
Dec 11, 2019

Conversation

sakridge
Copy link
Member

Problem

The accounts index never cleans up dead account keys, leaving a pubkey in the hash table pointing to a vec which will not be deallocated.

Summary of Changes

Detect when an account exists on no branches in purge zero lamport accounts and remove it from the index.

Fixes #

@sakridge sakridge requested a review from ryoqun December 10, 2019 21:52
@codecov
Copy link

codecov bot commented Dec 10, 2019

Codecov Report

Merging #7408 into master will increase coverage by <.1%.
The diff coverage is 100%.

@@           Coverage Diff            @@
##           master   #7408     +/-   ##
========================================
+ Coverage    80.6%   80.6%   +<.1%     
========================================
  Files         245     244      -1     
  Lines       48439   47778    -661     
========================================
- Hits        39048   38548    -500     
+ Misses       9391    9230    -161

for pubkey in purges.keys() {
reclaims.extend(accounts_index.purge(&pubkey));
let purge = accounts_index.purge(&pubkey);
Copy link
Member

@ryoqun ryoqun Dec 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: I think .1 and .0 isn't readable... So how about this using destructring?

let mut all_reclaims = Vec::new();
for ...
    let (reclaims, is_empty) = accounts_index...
    all_reclaims.extend(reclaims);
    if (is_empty) {
        dead_keys.push(...
    }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. That's better. Thanks.

Copy link
Member

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up the code into the fine details!

LGTM with nits

ryoqun
ryoqun previously approved these changes Dec 11, 2019
Copy link
Member

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Err, I've selected wrong radio button, so this is a re-submit to overwrite previous one)

Thanks for cleaning up the code into the fine details!

LGTM with nits

@mergify mergify bot dismissed ryoqun’s stale review December 11, 2019 18:17

Pull request has been modified.

@sakridge sakridge merged commit 0aa4dc9 into solana-labs:master Dec 11, 2019
@sakridge sakridge deleted the remove-dead-accounts branch December 11, 2019 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants