Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ledger-tool bigtable upload loop #26030

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions ledger-tool/src/bigtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use {
UiTransactionEncoding,
},
std::{
cmp::min,
collections::HashSet,
path::Path,
process::exit,
Expand All @@ -36,7 +37,7 @@ use {

async fn upload(
blockstore: Blockstore,
starting_slot: Slot,
mut starting_slot: Slot,
ending_slot: Option<Slot>,
force_reupload: bool,
config: solana_storage_bigtable::LedgerStorageConfig,
Expand All @@ -49,19 +50,29 @@ async fn upload(
force_reupload,
..ConfirmedBlockUploadConfig::default()
};
let blockstore = Arc::new(blockstore);

let ending_slot = ending_slot.unwrap_or_else(|| blockstore.last_root());

solana_ledger::bigtable_upload::upload_confirmed_blocks(
Arc::new(blockstore),
bigtable,
starting_slot,
ending_slot,
config,
Arc::new(AtomicBool::new(false)),
)
.await
.map(|last_slot_uploaded| {
while starting_slot <= ending_slot {
let current_ending_slot = min(
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(
blockstore.clone(),
bigtable.clone(),
starting_slot,
current_ending_slot,
config.clone(),
Arc::new(AtomicBool::new(false)),
)
.await?;
info!("last slot uploaded: {}", last_slot_uploaded);
})
starting_slot = last_slot_uploaded.saturating_add(1);
}
info!("No more blocks to upload.");
Ok(())
}

async fn delete_slots(
Expand Down
11 changes: 2 additions & 9 deletions ledger/src/bigtable_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn upload_confirmed_blocks(
blockstore: Arc<Blockstore>,
bigtable: solana_storage_bigtable::LedgerStorage,
starting_slot: Slot,
ending_slot: Option<Slot>,
ending_slot: Slot,
config: ConfirmedBlockUploadConfig,
exit: Arc<AtomicBool>,
) -> Result<Slot, Box<dyn std::error::Error>> {
Expand All @@ -60,14 +60,7 @@ pub async fn upload_confirmed_blocks(
starting_slot, err
)
})?
.map_while(|slot| {
if let Some(ending_slot) = &ending_slot {
if slot > *ending_slot {
return None;
}
}
Some(slot)
})
.map_while(|slot| (slot <= ending_slot).then(|| slot))
.collect();

if blockstore_slots.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/bigtable_upload_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl BigTableUploadService {
blockstore.clone(),
bigtable_ledger_storage.clone(),
start_slot,
Some(end_slot),
end_slot,
config.clone(),
exit.clone(),
));
Expand Down