From 81394cf92c0d9fc88fe9cefc035fe8e8999464f1 Mon Sep 17 00:00:00 2001 From: Tyera Date: Fri, 23 Dec 2022 11:11:27 -0700 Subject: [PATCH] Fix BigTable upload early return (#29378) * Change Err when slot range is empty to Ok and log; add method docs * Update var and log to be more correct * Promote log level to warn --- ledger-tool/src/bigtable.rs | 6 +++--- ledger/src/bigtable_upload.rs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ledger-tool/src/bigtable.rs b/ledger-tool/src/bigtable.rs index 772992d80f8a96..fae7fda6d260a7 100644 --- a/ledger-tool/src/bigtable.rs +++ b/ledger-tool/src/bigtable.rs @@ -60,7 +60,7 @@ async fn upload( ending_slot, starting_slot.saturating_add(config.max_num_slots_to_check as u64 * 2), ); - let last_slot_uploaded = solana_ledger::bigtable_upload::upload_confirmed_blocks( + let last_slot_checked = solana_ledger::bigtable_upload::upload_confirmed_blocks( blockstore.clone(), bigtable.clone(), starting_slot, @@ -69,8 +69,8 @@ async fn upload( Arc::new(AtomicBool::new(false)), ) .await?; - info!("last slot uploaded: {}", last_slot_uploaded); - starting_slot = last_slot_uploaded.saturating_add(1); + info!("last slot checked: {}", last_slot_checked); + starting_slot = last_slot_checked.saturating_add(1); } info!("No more blocks to upload."); Ok(()) diff --git a/ledger/src/bigtable_upload.rs b/ledger/src/bigtable_upload.rs index f5c40c23c0334b..ce96258e5b2cbb 100644 --- a/ledger/src/bigtable_upload.rs +++ b/ledger/src/bigtable_upload.rs @@ -41,6 +41,9 @@ struct BlockstoreLoadStats { pub elapsed: Duration, } +/// Uploads a range of blocks from a Blockstore to bigtable LedgerStorage +/// Returns the Slot of the last block checked. If no blocks in the range `[staring_slot, +/// ending_slot]` are found in Blockstore, this value is equal to `ending_slot`. pub async fn upload_confirmed_blocks( blockstore: Arc, bigtable: solana_storage_bigtable::LedgerStorage, @@ -61,7 +64,8 @@ pub async fn upload_confirmed_blocks( .collect(); if blockstore_slots.is_empty() { - return Err(format!("Ledger has no slots from {starting_slot} to {ending_slot:?}").into()); + warn!("Ledger has no slots from {starting_slot} to {ending_slot:?}"); + return Ok(ending_slot); } let first_blockstore_slot = blockstore_slots.first().unwrap();