File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
beacon_node/beacon_chain/src Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -206,8 +206,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
206206 drop ( sig_timer) ;
207207
208208 // Write the I/O batches to disk.
209+ // We fsync after each write because we need the writes to the blob and freezer DB to
210+ // be persisted if the writes to the hot DB are persisted. Without fsync we could end up
211+ // in a situation where the hot DB's anchor is updated but the actual blocks are forgotten
212+ // from disk.
209213 self . store . blobs_db . do_atomically ( blob_batch) ?;
214+ self . store . blobs_db . sync ( ) ?;
210215 self . store . cold_db . do_atomically ( cold_batch) ?;
216+ self . store . cold_db . sync ( ) ?;
211217
212218 let mut anchor_and_blob_batch = Vec :: with_capacity ( 2 ) ;
213219
@@ -237,6 +243,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
237243 . compare_and_set_anchor_info ( Some ( anchor_info) , Some ( new_anchor) ) ?,
238244 ) ;
239245 self . store . hot_db . do_atomically ( anchor_and_blob_batch) ?;
246+ self . store . hot_db . sync ( ) ?;
240247
241248 // If backfill has completed and the chain is configured to reconstruct historic states,
242249 // send a message to the background migrator instructing it to begin reconstruction.
You can’t perform that action at this time.
0 commit comments