Skip to content

Commit

Permalink
pr feedback: reword comments and write batch error message
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Feb 27, 2024
1 parent 348b918 commit 891b514
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
13 changes: 8 additions & 5 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,18 +1154,21 @@ impl Blockstore {
self.completed_slots_senders.lock().unwrap().clear();
}

/// Range-delete all entries which prefix matches the specified `slot`,
/// remove `slot`'s parent's SlotMeta next_slots list, and
/// clear `slot`'s SlotMeta (except for next_slots).
/// Clear `slot` from the Blockstore, see ``Blockstore::purge_slot_cleanup_chaining`
/// for more details.
///
/// This function currently requires `insert_shreds_lock`, as both
/// `clear_unconfirmed_slot()` and `insert_shreds_handle_duplicate()`
/// try to perform read-modify-write operation on [`cf::SlotMeta`] column
/// family.
pub fn clear_unconfirmed_slot(&self, slot: Slot) {
let _lock = self.insert_shreds_lock.lock().unwrap();
// Clear all slot related information, and cleanup slot meta by removing
// `slot` from parents `next_slots`, but retaining `slot`'s `next_slots`.
// Purge the slot and insert an empty `SlotMeta` with only the `next_slots` field preserved.
// Shreds inherently contain the slot of their parent which updates the parent's `next_slots`
// when the child is inserted through `Blockstore::handle_chaining()`.
// However we are only purging and repairing the parent slot here. Since the child will not be
// reinserted the chaining will be lost. In order for bank forks discovery to ingest the child,
// we must retain the chain by preserving `next_slots`.
match self.purge_slot_cleanup_chaining(slot) {
Ok(_) => {}
Err(BlockstoreError::SlotUnavailable) => error!(
Expand Down
20 changes: 9 additions & 11 deletions ledger/src/blockstore/blockstore_purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,12 @@ impl Blockstore {
slot_meta.clear_unconfirmed_slot();
write_batch.put::<cf::SlotMeta>(slot, &slot_meta)?;

if let Err(e) = self.db.write(write_batch) {
self.db.write(write_batch).inspect_err(|e| {
error!(
"Error: {:?} while submitting write batch for slot {:?} retrying...",
"Error: {:?} while submitting write batch for slot {:?}",
e, slot
);
return Err(e);
}
)
})?;
Ok(columns_purged)
}

Expand Down Expand Up @@ -220,13 +219,12 @@ impl Blockstore {
delete_range_timer.stop();

let mut write_timer = Measure::start("write_batch");
if let Err(e) = self.db.write(write_batch) {
self.db.write(write_batch).inspect(|e| {
error!(
"Error: {:?} while submitting write batch for slot {:?} retrying...",
e, from_slot
);
return Err(e);
}
"Error: {:?} while submitting write batch for purge from_slot {} to_slot {}",
e, from_slot, to_slot
)
})?;
write_timer.stop();

let mut purge_files_in_range_timer = Measure::start("delete_file_in_range");
Expand Down

0 comments on commit 891b514

Please sign in to comment.