-
Notifications
You must be signed in to change notification settings - Fork 255
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
Enable accountsdb_scan_account_storage_no_bank tests for hot storage #344
Enable accountsdb_scan_account_storage_no_bank tests for hot storage #344
Conversation
accounts-db/src/tiered_storage.rs
Outdated
// promote this to panic soon. | ||
// disabled due to many false positive warnings while running tests. | ||
// blocked by rpc's upgrade to jsonrpc v17 | ||
/* | ||
panic!( | ||
"TieredStorage failed to remove backing storage file '{}': {err}", | ||
self.path.display(), | ||
); | ||
);*/ | ||
inc_new_counter_info!("append_vec_drop_fail", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section was copied from the AppendVec. The test will fail without this as some tests sometimes create an empty AccountsFile instance without writing it causing nothing to be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which test(s) fail? Can we usually ManuallyDrop
, like we do in the append vec tests here?
agave/accounts-db/src/append_vec.rs
Lines 1205 to 1206 in b2f4fb3
// wrap AppendVec in ManuallyDrop to ensure we do not remove the backing file when dropped | |
let av = ManuallyDrop::new(AppendVec::new(path, true, 1024 * 1024)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, when we talked about this offline, can you check if the error is for "file not found" or not? If the error is something else, maybe panic still is the right call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The counter name should not be "append_vec" though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enabled tests here will fail because of this. But I think skipping no-such-file-or-directory error should address the problem as we previously discussed.
Manual-drop works as well.
thread 'accounts_db::tests::test_accountsdb_scan_account_storage_no_bank_one_slot' panicked at accounts-db/src/tiered_storage.rs:67:13:
TieredStorage failed to remove backing storage file '/var/folders/2_/848_htk13yb0b_r0wg105t400000gn/T/.tmpFVnzMY/run/0.0': No such file or directory (os error 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #446 that keeps the panic behavior but exclude io::ErrorKind::NotFound.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #344 +/- ##
=======================================
Coverage 81.8% 81.8%
=======================================
Files 843 843
Lines 228586 228677 +91
=======================================
+ Hits 187124 187209 +85
- Misses 41462 41468 +6 |
accounts-db/src/accounts_db.rs
Outdated
#[test] | ||
fn test_accountsdb_scan_account_storage_no_bank() { | ||
accountsdb_scan_account_storage_no_bank_test_case::<WritableAppendVecProvider>(); | ||
accountsdb_scan_account_storage_no_bank_test_case::<WritableHotStorageProvider>(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brooksprumo: Just want to get quick feedback from you. Here's the way that I am currently developing to enable accounts-db tests for both AppendVec and TieredStorage. Does it look good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may be able to use test_case
to generate these easier. It'll also then create two proper tests, so we can see pass/fail on each accounts file type separately.
Here's an example with generics: https://github.com/frondeus/test-case/blob/master/tests/acceptance_cases/cases_support_generics/src/lib.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! This is great! Thanks for the pointer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the test to use test_case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of anything better, so seems good for now. The non-test code should be monomorphized and the compiler should optimize any indirection away (I believe/hope!).
accounts-db/src/tiered_storage.rs
Outdated
// promote this to panic soon. | ||
// disabled due to many false positive warnings while running tests. | ||
// blocked by rpc's upgrade to jsonrpc v17 | ||
/* | ||
panic!( | ||
"TieredStorage failed to remove backing storage file '{}': {err}", | ||
self.path.display(), | ||
); | ||
);*/ | ||
inc_new_counter_info!("append_vec_drop_fail", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, when we talked about this offline, can you check if the error is for "file not found" or not? If the error is something else, maybe panic still is the right call.
accounts-db/src/tiered_storage.rs
Outdated
@@ -22,6 +22,7 @@ use { | |||
footer::{AccountBlockFormat, AccountMetaFormat}, | |||
hot::{HotStorageWriter, HOT_FORMAT}, | |||
index::IndexBlockFormat, | |||
log::log_enabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was for the log. Removed
accounts-db/src/tiered_storage.rs
Outdated
// promote this to panic soon. | ||
// disabled due to many false positive warnings while running tests. | ||
// blocked by rpc's upgrade to jsonrpc v17 | ||
/* | ||
panic!( | ||
"TieredStorage failed to remove backing storage file '{}': {err}", | ||
self.path.display(), | ||
); | ||
);*/ | ||
inc_new_counter_info!("append_vec_drop_fail", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The counter name should not be "append_vec" though.
accounts-db/src/accounts_db.rs
Outdated
#[test] | ||
fn test_accountsdb_scan_account_storage_no_bank() { | ||
accountsdb_scan_account_storage_no_bank_test_case::<WritableAppendVecProvider>(); | ||
accountsdb_scan_account_storage_no_bank_test_case::<WritableHotStorageProvider>(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may be able to use test_case
to generate these easier. It'll also then create two proper tests, so we can see pass/fail on each accounts file type separately.
Here's an example with generics: https://github.com/frondeus/test-case/blob/master/tests/acceptance_cases/cases_support_generics/src/lib.rs
accounts-db/src/accounts_db.rs
Outdated
@@ -1031,10 +1030,15 @@ pub struct AccountStorageEntry { | |||
} | |||
|
|||
impl AccountStorageEntry { | |||
pub fn new(path: &Path, slot: Slot, id: AppendVecId, file_size: u64) -> Self { | |||
pub fn new<T: WritableAccountsFileProvider>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only use T
when it's a container and the container can hold any arbitrary type.
How about something like AF
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Used AP (stands for AccountsFile Provider).
02462f9
to
ec97e39
Compare
Rebased on top of the updated #334. Used |
351322c
to
bdba36e
Compare
bdba36e
to
9b60781
Compare
@brooksprumo I think the other changes are no longer part of this pr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure this PR still built, I checked it out and rebased on master. It successfully passed cargo clippy --tests
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Problem
test_accountsdb_scan_account_storage_no_bank_one_slot and
test_accountsdb_scan_account_storage_no_bank only run for AppendVec.
Summary of Changes
Enable the above two tests to cover both AppendVec and HotStorage.
Test Plan
Run the newly enabled tests.
Dependency
#334, #446