Skip to content

Refactors AccountsBackgroundService if a snapshot request was not handled#6418

Merged
brooksprumo merged 3 commits intoanza-xyz:masterfrom
brooksprumo:abs/refactor
Jun 5, 2025
Merged

Refactors AccountsBackgroundService if a snapshot request was not handled#6418
brooksprumo merged 3 commits intoanza-xyz:masterfrom
brooksprumo:abs/refactor

Conversation

@brooksprumo
Copy link
Copy Markdown

@brooksprumo brooksprumo commented Jun 4, 2025

Problem

The main problem is #6295. As a means to that end, we need to ensure we don't clean past any enqueued snapshot request's slot.

Since we call flush and clean in multiple branches (if a snapshot request is not handled), it's not straight forward to share a "max cleanable slot" between them all.

Summary of Changes

Refactor the AccountsBackgroundService code, when a snapshot request was not handled, to make it possible to share a "max cleanable slot".

Note, needs to be backported to v2.3.

@brooksprumo brooksprumo self-assigned this Jun 4, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 76.92308% with 6 lines in your changes missing coverage. Please review.

Project coverage is 82.8%. Comparing base (347b25d) to head (36fd0ce).

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #6418     +/-   ##
=========================================
- Coverage    82.8%    82.8%   -0.1%     
=========================================
  Files         848      848             
  Lines      379479   379490     +11     
=========================================
- Hits       314588   314355    -233     
- Misses      64891    65135    +244     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +641 to +645
// if we're cleaning, then force flush, otherwise be lazy
bank.rc
.accounts
.accounts_db
.flush_accounts_cache(should_clean, Some(max_clean_slot_inclusive));
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

First change: unify flush

Previously, the else-if and the else branches both flush. One with force=true, and one with force=false. And that 'force' was based on if we're cleaning or not.

Comment on lines +635 to +636
// see the comments in Bank::clean_accounts() for why we sub 1 here
let max_clean_slot_inclusive = bank.slot().saturating_sub(1);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The next PR will change this max clean slot, and that'll be the final fix for the underlying issue. So we'll want to feel pretty good about this refactor first.

@brooksprumo brooksprumo marked this pull request as ready for review June 5, 2025 14:53
HaoranYi
HaoranYi previously approved these changes Jun 5, 2025
Copy link
Copy Markdown

@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.

@brooksprumo brooksprumo requested review from HaoranYi and roryharr June 5, 2025 17:09
Copy link
Copy Markdown

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm

@brooksprumo brooksprumo merged commit cedfdf8 into anza-xyz:master Jun 5, 2025
47 checks passed
@brooksprumo brooksprumo deleted the abs/refactor branch June 5, 2025 22:49
@brooksprumo brooksprumo removed the v2.3 label Jun 6, 2025
@mergify
Copy link
Copy Markdown

mergify bot commented Jun 6, 2025

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 Jun 6, 2025
fkouteib pushed a commit to fkouteib/agave that referenced this pull request Jun 7, 2025
brooksprumo added a commit that referenced this pull request Jun 9, 2025
brooksprumo added a commit that referenced this pull request Jun 9, 2025
…ot handled (backport of #6418) (#6451)

Refactors AccountsBackgroundService if a snapshot request was not handled (#6418)

(cherry picked from commit cedfdf8)

Co-authored-by: Brooks <brooks@anza.xyz>
mircea-c pushed a commit to mircea-c/agave that referenced this pull request Jun 12, 2025
mircea-c added a commit to mircea-c/agave that referenced this pull request Jun 12, 2025
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.

5 participants