Skip to content

Commit

Permalink
fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed Oct 20, 2023
1 parent b256e06 commit aff744c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,7 @@ impl ReplayStage {
epoch_slots_frozen_slots: &mut EpochSlotsFrozenSlots,
drop_bank_sender: &Sender<Vec<Arc<Bank>>>,
) {
bank_forks.read().unwrap().prune_program_cache(new_root);
let removed_banks = bank_forks.write().unwrap().set_root(
new_root,
accounts_background_request_sender,
Expand Down
5 changes: 5 additions & 0 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,11 @@ fn load_frozen_forks(
root = new_root_bank.slot();

leader_schedule_cache.set_root(new_root_bank);
new_root_bank
.loaded_programs_cache
.write()
.unwrap()
.prune(root, new_root_bank.epoch());
let _ = bank_forks.write().unwrap().set_root(
root,
accounts_background_request_sender,
Expand Down
19 changes: 10 additions & 9 deletions runtime/src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,23 @@ impl BankForks {
)
}

pub fn prune_program_cache(&self, root: Slot) {
self.banks.get(&root).map(|root_bank| {
root_bank
.loaded_programs_cache
.write()
.unwrap()
.prune(root, root_bank.epoch());
});
}

pub fn set_root(
&mut self,
root: Slot,
accounts_background_request_sender: &AbsRequestSender,
highest_super_majority_root: Option<Slot>,
) -> Vec<Arc<Bank>> {
let program_cache_prune_start = Instant::now();
let root_bank = self
.banks
.get(&root)
.expect("root bank didn't exist in bank_forks");
root_bank
.loaded_programs_cache
.write()
.unwrap()
.prune(root, root_bank.epoch());
let set_root_start = Instant::now();
let (removed_banks, set_root_metrics) = self.do_set_root_return_metrics(
root,
Expand Down

0 comments on commit aff744c

Please sign in to comment.