Skip to content

Commit

Permalink
storage-bigtable: delete entry rows if they exist when deleting confi…
Browse files Browse the repository at this point in the history
…rmed block (solana-labs#34261)

Delete entry rows if they exist
  • Loading branch information
CriesofCarrots authored Nov 29, 2023
1 parent 2bde5c3 commit ded307a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions storage-bigtable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,13 @@ impl LedgerStorage {
vec![]
};

let entries_exist = self
.connection
.client()
.row_key_exists("entries", slot_to_entries_key(slot))
.await
.is_ok_and(|x| x);

if !dry_run {
if !address_slot_rows.is_empty() {
self.connection
Expand All @@ -1146,17 +1153,24 @@ impl LedgerStorage {
.await?;
}

if entries_exist {
self.connection
.delete_rows_with_retry("entries", &[slot_to_entries_key(slot)])
.await?;
}

self.connection
.delete_rows_with_retry("blocks", &[slot_to_blocks_key(slot)])
.await?;
}

info!(
"{}deleted ledger data for slot {}: {} transaction rows, {} address slot rows",
"{}deleted ledger data for slot {}: {} transaction rows, {} address slot rows, {} entry row",
if dry_run { "[dry run] " } else { "" },
slot,
tx_deletion_rows.len(),
address_slot_rows.len()
address_slot_rows.len(),
if entries_exist { "with" } else {"WITHOUT"}
);

Ok(())
Expand Down

0 comments on commit ded307a

Please sign in to comment.