Skip to content

accounts-db: scan storages through the file activated on the reader - #15916

Merged
brooksprumo merged 1 commit into
anza-xyz:masterfrom
kskalski:ks/scan_caller_file
Oct 9, 2026
Merged

brooksprumo merged 1 commit into
anza-xyz:masterfrom
kskalski:ks/scan_caller_file

Conversation

@kskalski

@kskalski kskalski commented Oct 9, 2026 •

Copy link
Copy Markdown

Problem

  • SplitFile::scan_accounts_with_data replaces the file that the caller set on the reader with its own data file (as opposed to AppendVec::scan_accounts_with). This makes snapshot archiving with direct I/O read split storages through the page cache.
  • AccountStorageEntry scans only through the storage's own fd, so index generation can't read storages through a direct I/O fd while still excluding obsolete accounts.

Summary of Changes

  • normalize the storage scan API: the scan_accounts_with* functions read the file already activated on the reader in AccountStorageEntry, AccountsFile and every storage format, and scan_accounts activates the storage's own file with AccountsFile::set_file_on_reader before delegating to it
  • return the account data length from open_file_for_archive as the read limit, since direct reads must stay within the data file (excludes a split file's metadata)

Testing

test_scan_accounts_with_data_reads_callers_data_file fails before this change.

Problem:
- `SplitFile::scan_accounts_with_data` replaces the file that the caller set on the reader with its own data file, while `AppendVec::scan_accounts_with` keeps it. This makes snapshot archiving with direct I/O read split storages through the page cache.
- `AccountStorageEntry` scans only through the storage's own fd, so index generation can't read storages through a direct I/O fd while still excluding obsolete accounts.

Summary of Changes:
- normalize the storage scan API: the `scan_accounts_with*` functions read the file already activated on the reader in `AccountStorageEntry`, `AccountsFile` and every storage format, and `scan_accounts` activates the storage's own file with `AccountsFile::set_file_on_reader` before delegating to it
- return the account data length from `open_file_for_archive` as the read limit, since direct reads must stay within the data file (excludes a split file's metadata)

Testing: `test_scan_accounts_with_data_reads_callers_data_file` fails before this change.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.19048% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.3%. Comparing base (5faf023) to head (4e02295).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #15916    +/-   ##
========================================
  Coverage    82.2%    82.3%            
========================================
  Files         937      937            
  Lines      373394   373451    +57     
========================================
+ Hits       307192   307386   +194     
+ Misses      66202    66065   -137     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

/// Activates this instance's account data file on `reader`.
pub(crate) fn set_file_on_reader<'a>(

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.

this isn't the nicest API, we could avoid it by making account_data_file() pub(crate) and tweaking a few callsites to do the same work...

@kskalski
kskalski marked this pull request as ready for review October 9, 2026 11:03
@kskalski
kskalski requested a review from a team as a code owner October 9, 2026 11:03

@brooksprumo brooksprumo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:shipit:

I didn't like the separate scan_accounts() vs scan_accounts_with() fns, so happy to see this direction.

Comment on lines +317 to +327
/// Returns the file holding the account data and its length; a split file without a data file
/// returns its meta file with length 0.
fn account_data_file(&self) -> (&File, FileSize) {
match self {
Self::AppendVec(av) => (av.file(), av.len() as FileSize),
Self::Split(split) => match split.data_file() {
Some(data_file) => (data_file, split.data_len()),
None => (split.meta_file(), 0),
},
}
}

@brooksprumo brooksprumo Oct 9, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Related to #15889, we can likely have this fn return an Option. And then a Split file with no data file will return None.

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.

yap, that will be the requirement for combining with that change

@kskalski
kskalski added this pull request to the merge queue Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@brooksprumo
brooksprumo added this pull request to the merge queue Oct 9, 2026
Merged via the queue into anza-xyz:master with commit 94cb48f Oct 9, 2026
49 checks passed
@kskalski
kskalski deleted the ks/scan_caller_file branch October 9, 2026 14:00
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.

3 participants