Repository navigation
accounts-db: scan storages through the file activated on the reader - #15916
Conversation
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 Report❌ Patch coverage is 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:
|
| } | ||
|
|
||
| /// Activates this instance's account data file on `reader`. | ||
| pub(crate) fn set_file_on_reader<'a>( |
There was a problem hiding this comment.
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...
brooksprumo
left a comment
There was a problem hiding this comment.
![]()
I didn't like the separate scan_accounts() vs scan_accounts_with() fns, so happy to see this direction.
| /// 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), | ||
| }, | ||
| } | ||
| } |
There was a problem hiding this comment.
Related to #15889, we can likely have this fn return an Option. And then a Split file with no data file will return None.
There was a problem hiding this comment.
yap, that will be the requirement for combining with that change
Problem
SplitFile::scan_accounts_with_datareplaces the file that the caller set on the reader with its own data file (as opposed toAppendVec::scan_accounts_with). This makes snapshot archiving with direct I/O read split storages through the page cache.AccountStorageEntryscans 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
scan_accounts_with*functions read the file already activated on the reader inAccountStorageEntry,AccountsFileand every storage format, andscan_accountsactivates the storage's own file withAccountsFile::set_file_on_readerbefore delegating to itopen_file_for_archiveas 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_filefails before this change.