diff --git a/ledger-tool/src/bigtable.rs b/ledger-tool/src/bigtable.rs index fae7fda6d260a7..f99ed35ae46cd6 100644 --- a/ledger-tool/src/bigtable.rs +++ b/ledger-tool/src/bigtable.rs @@ -38,7 +38,7 @@ use { async fn upload( blockstore: Blockstore, - mut starting_slot: Slot, + starting_slot: Option, ending_slot: Option, force_reupload: bool, config: solana_storage_bigtable::LedgerStorageConfig, @@ -53,6 +53,16 @@ async fn upload( }; let blockstore = Arc::new(blockstore); + let starting_slot = if let Some(starting_slot) = starting_slot { + Ok(starting_slot) + } else { + // It is possible that the slot returned below could get purged by + // LedgerCleanupService before upload_confirmed_blocks() get the value. + // However, this is ok as upload_confirmed_blocks() doesn't need this + // exact slot to be in ledger. + blockstore.get_first_available_block() + }; + let mut starting_slot = starting_slot?; let ending_slot = ending_slot.unwrap_or_else(|| blockstore.last_root()); while starting_slot <= ending_slot { @@ -640,7 +650,7 @@ pub fn bigtable_process_command( let future = match (subcommand, sub_matches) { ("upload", Some(arg_matches)) => { - let starting_slot = value_t!(arg_matches, "starting_slot", Slot).unwrap_or(0); + let starting_slot = value_t!(arg_matches, "starting_slot", Slot).ok(); let ending_slot = value_t!(arg_matches, "ending_slot", Slot).ok(); let force_reupload = arg_matches.is_present("force_reupload"); let blockstore = crate::open_blockstore(