Fix bug where ReplayStage holds an Arc<Bank> for process lifetime (#31267)
* Fix bug where ReplayStage holds an Arc<Bank> for process lifetime When ReplayStage::new() kicks off, it needs to do some setup with the working bank prior to entering the main processing loop. This setup is done before entering the main processing loop; however, a bug made it such that an Arc<Bank> remained in scope after the processing loop had been entered. The processing loop is only exited when the process exits, so this means that Bank was being held for the lifetime of the process. This is a waste of resources and prevents background cleanup. * clippy
This commit is contained in:
parent
a5275f8839
commit
377ba53a31
|
@ -561,7 +561,7 @@ impl ReplayStage {
|
|||
Self::reset_poh_recorder(
|
||||
&my_pubkey,
|
||||
&blockstore,
|
||||
&working_bank,
|
||||
working_bank,
|
||||
&poh_recorder,
|
||||
&leader_schedule_cache,
|
||||
);
|
||||
|
@ -931,7 +931,7 @@ impl ReplayStage {
|
|||
Self::reset_poh_recorder(
|
||||
&my_pubkey,
|
||||
&blockstore,
|
||||
&reset_bank,
|
||||
reset_bank.clone(),
|
||||
&poh_recorder,
|
||||
&leader_schedule_cache,
|
||||
);
|
||||
|
@ -2358,34 +2358,30 @@ impl ReplayStage {
|
|||
fn reset_poh_recorder(
|
||||
my_pubkey: &Pubkey,
|
||||
blockstore: &Blockstore,
|
||||
bank: &Arc<Bank>,
|
||||
bank: Arc<Bank>,
|
||||
poh_recorder: &RwLock<PohRecorder>,
|
||||
leader_schedule_cache: &LeaderScheduleCache,
|
||||
) {
|
||||
let slot = bank.slot();
|
||||
let tick_height = bank.tick_height();
|
||||
|
||||
let next_leader_slot = leader_schedule_cache.next_leader_slot(
|
||||
my_pubkey,
|
||||
bank.slot(),
|
||||
bank,
|
||||
slot,
|
||||
&bank,
|
||||
Some(blockstore),
|
||||
GRACE_TICKS_FACTOR * MAX_GRACE_SLOTS,
|
||||
);
|
||||
poh_recorder
|
||||
.write()
|
||||
.unwrap()
|
||||
.reset(bank.clone(), next_leader_slot);
|
||||
|
||||
poh_recorder.write().unwrap().reset(bank, next_leader_slot);
|
||||
|
||||
let next_leader_msg = if let Some(next_leader_slot) = next_leader_slot {
|
||||
format!("My next leader slot is {}", next_leader_slot.0)
|
||||
} else {
|
||||
"I am not in the leader schedule yet".to_owned()
|
||||
};
|
||||
|
||||
info!(
|
||||
"{} reset PoH to tick {} (within slot {}). {}",
|
||||
my_pubkey,
|
||||
bank.tick_height(),
|
||||
bank.slot(),
|
||||
next_leader_msg,
|
||||
"{my_pubkey} reset PoH to tick {tick_height} (within slot {slot}). {next_leader_msg}",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue