Skip to content

Commit

Permalink
Replaces dropping cf with deleting range of all items to avoid a pani…
Browse files Browse the repository at this point in the history
…c when trying to open the db with that column family.
  • Loading branch information
arya2 committed Oct 25, 2024
1 parent 01f33c2 commit 14a225e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
12 changes: 0 additions & 12 deletions zebra-state/src/service/finalized_state/disk_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,18 +866,6 @@ impl DiskDb {
DB::open_cf_descriptors(&db_options, &path, column_families)
};

#[cfg(not(feature = "indexer"))]
let db_result = match db_result {
Ok(mut db) if db_kind == STATE_DATABASE_KIND => {
if let Err(err) = db.drop_cf(super::zebra_db::transparent::TX_LOC_BY_SPENT_OUT_LOC)
{
warn!(?err, "failed to drop unused column family");
}
Ok(db)
}
other => other,
};

match db_result {
Ok(db) => {
info!("Opened Zebra state cache at {}", path.display());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ pub fn run(
return Err(CancelFormatChange);
}

// The `TX_LOC_BY_SPENT_OUT_LOC` column family should be dropped
// when opening the database without the `indexer` feature.
let _ = zebra_db
.tx_loc_by_spent_output_loc_cf()
.new_batch_for_writing()
.zs_delete_range(
&crate::OutputLocation::from_output_index(crate::TransactionLocation::MIN, 0),
&crate::OutputLocation::from_output_index(crate::TransactionLocation::MAX, u32::MAX),
)
.write_batch();

if !matches!(cancel_receiver.try_recv(), Err(TryRecvError::Empty)) {
return Err(CancelFormatChange);
}

(0..=initial_tip_height.0)
.into_par_iter()
Expand Down

0 comments on commit 14a225e

Please sign in to comment.