storage-bigtable: delete entry rows if they exist when deleting confirmed block (#34261)

Delete entry rows if they exist
This commit is contained in:
Tyera 2023-11-28 18:18:46 -07:00 committed by GitHub
parent 2bde5c3cb2
commit ded307adb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 2 deletions

View File

@ -1133,6 +1133,13 @@ impl LedgerStorage {
vec![] 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 !dry_run {
if !address_slot_rows.is_empty() { if !address_slot_rows.is_empty() {
self.connection self.connection
@ -1146,17 +1153,24 @@ impl LedgerStorage {
.await?; .await?;
} }
if entries_exist {
self.connection
.delete_rows_with_retry("entries", &[slot_to_entries_key(slot)])
.await?;
}
self.connection self.connection
.delete_rows_with_retry("blocks", &[slot_to_blocks_key(slot)]) .delete_rows_with_retry("blocks", &[slot_to_blocks_key(slot)])
.await?; .await?;
} }
info!( 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 { "" }, if dry_run { "[dry run] " } else { "" },
slot, slot,
tx_deletion_rows.len(), tx_deletion_rows.len(),
address_slot_rows.len() address_slot_rows.len(),
if entries_exist { "with" } else {"WITHOUT"}
); );
Ok(()) Ok(())