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

Reclaims more old accounts in clean #4044

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

brooksprumo
Copy link

Problem

In clean_accounts(), if there are old storages and old accounts beyond what is expected, we do not always reclaim them. This is because when scanning the candidates during clean, if the account's latest slot in the slot list is not in the uncleaned_roots list, we don't collect reclaims.

This can happen if there are candidates from old/ancient slots, where their newest entry is in a slot that is not being visited by clean. We would find multiple entries for this candidate in the index, yet determine not to collect reclaims.

Summary of Changes

Collect reclaims on candidates that have slot lists greater than one entry, and if they are all cleanable (i.e. rooted).

@brooksprumo brooksprumo self-assigned this Dec 10, 2024
@jeffwashington
Copy link

this looks correct. This seems like we can explain now why the brute force method wasn't working, too. And, since we were handling duplicates on the index correctly when we were starting with the in-mem index only. This seems correct.

HaoranYi
HaoranYi previously approved these changes Dec 10, 2024
Copy link

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

Nice find.
looks correct to me.

@brooksprumo
Copy link
Author

I spun up a mnb node with the disk index disabled to see how it performed. Here's some results:

clean always has a lot of work to do on the first iteration. And we see it removing the old slots:
Screenshot 2024-12-10 at 4 57 19 PM

And since we're cleaning up reclaims, shrink can do a better job now too, purging lots of zero lamport accounts:
Screenshot 2024-12-10 at 4 57 56 PM

@brooksprumo brooksprumo marked this pull request as ready for review December 10, 2024 22:08
Copy link

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

lgtm

@HaoranYi HaoranYi self-requested a review December 11, 2024 20:39
Copy link

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

If max_clean_root_inclusive is none, we need to follow the old rule, i.e. slots must be in self.uncleaned_roots...

@HaoranYi
Copy link

Recently, we have seen a few clean related issues with different CLI configuration for validators.

I am trying to think carefully about different ways that clean might be broken when the validator is running with different configurations, i.e. w/o disk index; w/o snapshot generation ...

@brooksprumo brooksprumo requested a review from HaoranYi December 11, 2024 21:47
purges_old_accounts_local += 1;
useless = false;
}
// Note, this next if-block is only kept to maintain the

Choose a reason for hiding this comment

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

seems like we could get rid of this metric code and stat. or at least make it a fn to simplify the code in this more critical code path to make it easier to understand and verify correct. THis can be done later.

Copy link
Author

Choose a reason for hiding this comment

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

Yep, I agree. I'll save it for later to keep this PR small, to make it simpler to backport.

@brooksprumo brooksprumo merged commit 3d43824 into anza-xyz:master Dec 12, 2024
40 checks passed
@brooksprumo brooksprumo deleted the clean/fix-reclaims branch December 12, 2024 19:38
@brooksprumo brooksprumo added v2.0 Backport to v2.0 branch v2.1 Backport to v2.1 branch labels Dec 12, 2024
Copy link

mergify bot commented Dec 12, 2024

Backports to the stable branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule.

Copy link

mergify bot commented Dec 12, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

mergify bot pushed a commit that referenced this pull request Dec 12, 2024
(cherry picked from commit 3d43824)

# Conflicts:
#	accounts-db/src/accounts_db.rs
#	accounts-db/src/accounts_db/tests.rs
mergify bot pushed a commit that referenced this pull request Dec 12, 2024
(cherry picked from commit 3d43824)

# Conflicts:
#	accounts-db/src/accounts_db.rs
#	accounts-db/src/accounts_db/tests.rs
brooksprumo added a commit that referenced this pull request Dec 18, 2024
* Reclaims more old accounts in `clean` (#4044)

(cherry picked from commit 3d43824)

# Conflicts:
#	accounts-db/src/accounts_db.rs
#	accounts-db/src/accounts_db/tests.rs

* fixes merge conflicts

---------

Co-authored-by: Brooks <brooks@anza.xyz>
brooksprumo added a commit that referenced this pull request Dec 18, 2024
* Reclaims more old accounts in `clean` (#4044)

(cherry picked from commit 3d43824)

# Conflicts:
#	accounts-db/src/accounts_db.rs
#	accounts-db/src/accounts_db/tests.rs

* fix merge conflicts

---------

Co-authored-by: Brooks <brooks@anza.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.0 Backport to v2.0 branch v2.1 Backport to v2.1 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants