mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 06:44:35 +00:00
Hold HeadTracker lock until persisting to disk (#5084)
* Fix head tracker drop order on un-ordered shutdown * lint --------- Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -805,10 +805,11 @@ where
|
||||
//
|
||||
// This *must* be stored before constructing the `BeaconChain`, so that its `Drop` instance
|
||||
// doesn't write a `PersistedBeaconChain` without the rest of the batch.
|
||||
let head_tracker_reader = head_tracker.0.read();
|
||||
self.pending_io_batch.push(BeaconChain::<
|
||||
Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>,
|
||||
>::persist_head_in_batch_standalone(
|
||||
genesis_block_root, &head_tracker
|
||||
genesis_block_root, &head_tracker_reader
|
||||
));
|
||||
self.pending_io_batch.push(BeaconChain::<
|
||||
Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>,
|
||||
@@ -819,6 +820,7 @@ where
|
||||
.hot_db
|
||||
.do_atomically(self.pending_io_batch)
|
||||
.map_err(|e| format!("Error writing chain & metadata to disk: {:?}", e))?;
|
||||
drop(head_tracker_reader);
|
||||
|
||||
let genesis_validators_root = head_snapshot.beacon_state.genesis_validators_root();
|
||||
let genesis_time = head_snapshot.beacon_state.genesis_time();
|
||||
|
||||
Reference in New Issue
Block a user