From ded307adb328a34a56a66b5a04eb662fd590484a Mon Sep 17 00:00:00 2001 From: Tyera Date: Tue, 28 Nov 2023 18:18:46 -0700 Subject: [PATCH] storage-bigtable: delete entry rows if they exist when deleting confirmed block (#34261) Delete entry rows if they exist --- storage-bigtable/src/lib.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/storage-bigtable/src/lib.rs b/storage-bigtable/src/lib.rs index b1f889e203c20a..0e7972fb683937 100644 --- a/storage-bigtable/src/lib.rs +++ b/storage-bigtable/src/lib.rs @@ -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 @@ -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(())