Skip to content

Commit

Permalink
Use read_recursive locks in database (#2417)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Jul 8, 2021
1 parent 3a2306f commit 367930b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
let high_restore_point_idx = low_restore_point_idx + 1;

// Acquire the read lock, so that the split can't change while this is happening.
let split = self.split.read();
let split = self.split.read_recursive();

let low_restore_timer = metrics::start_timer(&metrics::LOAD_LOW_RESTORE_POINT_TIME);
let low_restore_point = self.load_restore_point_by_index(low_restore_point_idx)?;
Expand Down Expand Up @@ -950,7 +950,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>

/// Fetch a copy of the current split slot from memory.
pub fn get_split_slot(&self) -> Slot {
self.split.read().slot
self.split.read_recursive().slot
}

/// Fetch the slot of the most recently stored restore point.
Expand Down Expand Up @@ -1123,7 +1123,7 @@ pub fn migrate_database<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>(
// 0. Check that the migration is sensible.
// The new frozen head must increase the current split slot, and lie on an epoch
// boundary (in order for the hot state summary scheme to work).
let current_split_slot = store.split.read().slot;
let current_split_slot = store.split.read_recursive().slot;

if frozen_head.slot() < current_split_slot {
return Err(HotColdDBError::FreezeSlotError {
Expand Down

0 comments on commit 367930b

Please sign in to comment.