From 7484202282df129fff2d3e3811be5a0bcc06b774 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Thu, 23 Jul 2020 18:57:15 -0600 Subject: [PATCH] Return root when bank not found (#11188) * Return root when bank not found * Apply suggestions from code review Co-authored-by: Tyera Eulberg Co-authored-by: Tyera Eulberg --- core/src/rpc.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 31ee28f13d..588ba80596 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -133,7 +133,24 @@ impl JsonRpcRequestProcessor { } }; - r_bank_forks.get(slot).cloned().unwrap() + r_bank_forks.get(slot).cloned().unwrap_or_else(|| { + // We log an error instead of returning an error, because all known error cases + // are due to known bugs that should be fixed instead. + // + // The slot may not be found as a result of a known bug in snapshot creation, where + // the bank at the given slot was not included in the snapshot. + // Also, it may occur after an old bank has been purged from BankForks and a new + // BlockCommitmentCache has not yet arrived. To make this case impossible, + // BlockCommitmentCache should hold an `Arc` everywhere it currently holds + // a slot. + // + // For more information, see https://github.com/solana-labs/solana/issues/11078 + error!( + "Bank with {:?} not found at slot: {:?}", + commitment_level, slot + ); + r_bank_forks.root_bank().clone() + }) } pub fn new(