Hack to skip cleanup_dead_slots upon snapshot load
This commit is contained in:
parent
1ca4913328
commit
5d9130a3c4
|
@ -447,16 +447,18 @@ pub fn bank_from_archive<P: AsRef<Path>>(
|
||||||
let mut snapshot_version = String::new();
|
let mut snapshot_version = String::new();
|
||||||
File::open(unpacked_version_file).and_then(|mut f| f.read_to_string(&mut snapshot_version))?;
|
File::open(unpacked_version_file).and_then(|mut f| f.read_to_string(&mut snapshot_version))?;
|
||||||
|
|
||||||
let bank = rebuild_bank_from_snapshots(
|
let mut bank = rebuild_bank_from_snapshots(
|
||||||
snapshot_version.trim(),
|
snapshot_version.trim(),
|
||||||
account_paths,
|
account_paths,
|
||||||
&unpacked_snapshots_dir,
|
&unpacked_snapshots_dir,
|
||||||
unpacked_accounts_dir,
|
unpacked_accounts_dir,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
bank.work_around_dead_slots_cleaning_bug(true);
|
||||||
if !bank.verify_snapshot_bank() {
|
if !bank.verify_snapshot_bank() {
|
||||||
panic!("Snapshot bank for slot {} failed to verify", bank.slot());
|
panic!("Snapshot bank for slot {} failed to verify", bank.slot());
|
||||||
}
|
}
|
||||||
|
bank.work_around_dead_slots_cleaning_bug(false);
|
||||||
measure.stop();
|
measure.stop();
|
||||||
info!("{}", measure);
|
info!("{}", measure);
|
||||||
|
|
||||||
|
|
|
@ -452,6 +452,8 @@ pub struct AccountsDB {
|
||||||
min_num_stores: usize,
|
min_num_stores: usize,
|
||||||
|
|
||||||
pub bank_hashes: RwLock<HashMap<Slot, BankHashInfo>>,
|
pub bank_hashes: RwLock<HashMap<Slot, BankHashInfo>>,
|
||||||
|
|
||||||
|
pub dont_cleanup_dead_slots: AtomicBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AccountsDB {
|
impl Default for AccountsDB {
|
||||||
|
@ -474,6 +476,7 @@ impl Default for AccountsDB {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
min_num_stores: num_threads,
|
min_num_stores: num_threads,
|
||||||
bank_hashes: RwLock::new(bank_hashes),
|
bank_hashes: RwLock::new(bank_hashes),
|
||||||
|
dont_cleanup_dead_slots: AtomicBool::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1296,6 +1299,10 @@ impl AccountsDB {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cleanup_dead_slots(&self, dead_slots: &mut HashSet<Slot>) {
|
fn cleanup_dead_slots(&self, dead_slots: &mut HashSet<Slot>) {
|
||||||
|
if self.dont_cleanup_dead_slots.load(Ordering::Relaxed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if !dead_slots.is_empty() {
|
if !dead_slots.is_empty() {
|
||||||
{
|
{
|
||||||
let mut index = self.accounts_index.write().unwrap();
|
let mut index = self.accounts_index.write().unwrap();
|
||||||
|
@ -2290,10 +2297,10 @@ pub mod tests {
|
||||||
assert_load_account(&accounts, current_slot, pubkey, zero_lamport);
|
assert_load_account(&accounts, current_slot, pubkey, zero_lamport);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn with_chained_zero_lamport_accounts<F>(f: F)
|
||||||
fn test_accounts_purge_chained() {
|
where
|
||||||
solana_logger::setup();
|
F: Fn(AccountsDB, Slot) -> (AccountsDB, bool),
|
||||||
|
{
|
||||||
let some_lamport = 223;
|
let some_lamport = 223;
|
||||||
let zero_lamport = 0;
|
let zero_lamport = 0;
|
||||||
let dummy_lamport = 999;
|
let dummy_lamport = 999;
|
||||||
|
@ -2332,8 +2339,12 @@ pub mod tests {
|
||||||
accounts.store(current_slot, &[(&dummy_pubkey, &dummy_account)]);
|
accounts.store(current_slot, &[(&dummy_pubkey, &dummy_account)]);
|
||||||
accounts.add_root(current_slot);
|
accounts.add_root(current_slot);
|
||||||
|
|
||||||
purge_zero_lamport_accounts(&accounts, current_slot);
|
let (accounts, skip_account_assertion) = f(accounts, current_slot);
|
||||||
let accounts = reconstruct_accounts_db_via_serialization(&accounts, current_slot);
|
|
||||||
|
assert_eq!(4, accounts.accounts_index.read().unwrap().roots.len());
|
||||||
|
if skip_account_assertion {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert_load_account(&accounts, current_slot, pubkey, some_lamport);
|
assert_load_account(&accounts, current_slot, pubkey, some_lamport);
|
||||||
assert_load_account(&accounts, current_slot, purged_pubkey1, 0);
|
assert_load_account(&accounts, current_slot, purged_pubkey1, 0);
|
||||||
|
@ -2341,6 +2352,29 @@ pub mod tests {
|
||||||
assert_load_account(&accounts, current_slot, dummy_pubkey, dummy_lamport);
|
assert_load_account(&accounts, current_slot, dummy_pubkey, dummy_lamport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_accounts_purge_chained_purge_before_snapshot_restore() {
|
||||||
|
solana_logger::setup();
|
||||||
|
with_chained_zero_lamport_accounts(|accounts, current_slot| {
|
||||||
|
purge_zero_lamport_accounts(&accounts, current_slot);
|
||||||
|
let accounts = reconstruct_accounts_db_via_serialization(&accounts, current_slot);
|
||||||
|
(accounts, false)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_accounts_purge_chained_purge_after_snapshot_restore() {
|
||||||
|
solana_logger::setup();
|
||||||
|
with_chained_zero_lamport_accounts(|accounts, current_slot| {
|
||||||
|
let accounts = reconstruct_accounts_db_via_serialization(&accounts, current_slot);
|
||||||
|
accounts
|
||||||
|
.dont_cleanup_dead_slots
|
||||||
|
.store(true, Ordering::Relaxed);
|
||||||
|
purge_zero_lamport_accounts(&accounts, current_slot);
|
||||||
|
(accounts, true)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn test_store_account_stress() {
|
fn test_store_account_stress() {
|
||||||
|
|
|
@ -1730,6 +1730,14 @@ impl Bank {
|
||||||
self.rc.parent = RwLock::new(Some(parent.clone()));
|
self.rc.parent = RwLock::new(Some(parent.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn work_around_dead_slots_cleaning_bug(&mut self, flag: bool) {
|
||||||
|
self.rc
|
||||||
|
.accounts
|
||||||
|
.accounts_db
|
||||||
|
.dont_cleanup_dead_slots
|
||||||
|
.store(flag, Ordering::Relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_inflation(&self, inflation: Inflation) {
|
pub fn set_inflation(&self, inflation: Inflation) {
|
||||||
*self.inflation.write().unwrap() = inflation;
|
*self.inflation.write().unwrap() = inflation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue