@@ -163,11 +163,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
163163 let tx_thread = if config. blocking {
164164 None
165165 } else {
166- Some ( Mutex :: new ( Self :: spawn_thread (
167- db. clone ( ) ,
168- prev_migration. clone ( ) ,
169- log. clone ( ) ,
170- ) ) )
166+ Some ( Mutex :: new ( Self :: spawn_thread ( db. clone ( ) , log. clone ( ) ) ) )
171167 } ;
172168 Self {
173169 db,
@@ -236,11 +232,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
236232
237233 // Restart the background thread if it has crashed.
238234 if let Err ( tx_err) = tx. send ( notif) {
239- let ( new_tx, new_thread) = Self :: spawn_thread (
240- self . db . clone ( ) ,
241- self . prev_migration . clone ( ) ,
242- self . log . clone ( ) ,
243- ) ;
235+ let ( new_tx, new_thread) = Self :: spawn_thread ( self . db . clone ( ) , self . log . clone ( ) ) ;
244236
245237 * tx = new_tx;
246238 let old_thread = mem:: replace ( thread, new_thread) ;
@@ -292,6 +284,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
292284 drop ( prev_migration) ;
293285
294286 debug ! ( log, "Database consolidation started" ) ;
287+ let timer = std:: time:: Instant :: now ( ) ;
295288
296289 let finalized_state_root = notif. finalized_state_root ;
297290 let finalized_block_root = notif. finalized_checkpoint . root ;
@@ -358,7 +351,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
358351 Err ( Error :: HotColdDBError ( HotColdDBError :: FreezeSlotUnaligned ( slot) ) ) => {
359352 debug ! (
360353 log,
361- "Database migration postponed, unaligned finalized block" ;
354+ "Database migration postponed due to unaligned finalized block" ;
362355 "slot" => slot. as_u64( )
363356 ) ;
364357 }
@@ -379,18 +372,21 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
379372 notif. finalized_checkpoint . epoch ,
380373 log,
381374 ) {
382- warn ! ( log, "Database compaction failed" ; "error" => format! ( "{:?}" , e ) ) ;
375+ warn ! ( log, "Database compaction failed" ; "error" => ?e ) ;
383376 }
384377
385- debug ! ( log, "Database consolidation complete" ) ;
378+ debug ! (
379+ log,
380+ "Database consolidation complete" ;
381+ "running_time_ms" => timer. elapsed( ) . as_millis( )
382+ ) ;
386383 }
387384
388385 /// Spawn a new child thread to run the migration process.
389386 ///
390387 /// Return a channel handle for sending requests to the thread.
391388 fn spawn_thread (
392389 db : Arc < HotColdDB < E , Hot , Cold > > ,
393- prev_migration : Arc < Mutex < PrevMigration > > ,
394390 log : Logger ,
395391 ) -> (
396392 crossbeam_channel:: Sender < Notification > ,
@@ -458,35 +454,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
458454
459455 // Do the finalization migration.
460456 if let Some ( notif) = migrate_notif {
461- let timer = std:: time:: Instant :: now ( ) ;
462-
463- let mut prev_migration = prev_migration. lock ( ) ;
464-
465- // Do not run too frequently.
466- let epoch = notif. finalized_checkpoint . epoch ;
467- if epoch < prev_migration. epoch + prev_migration. epochs_per_migration {
468- debug ! (
469- log,
470- "Finalization migration deferred" ;
471- "last_finalized_epoch" => prev_migration. epoch,
472- "new_finalized_epoch" => epoch,
473- "epochs_per_migration" => prev_migration. epochs_per_migration,
474- ) ;
475- continue ;
476- }
477-
478- // We intend to run at this epoch, update the in-memory record of the last epoch
479- // at which we ran. This value isn't tracked on disk so we will always migrate
480- // on the first finalization after startup.
481- prev_migration. epoch = epoch;
482-
483457 Self :: run_migration ( db. clone ( ) , notif. to_owned ( ) , & log) ;
484-
485- info ! (
486- log,
487- "Finished finalization migration" ;
488- "running_time_ms" => timer. elapsed( ) . as_millis( )
489- ) ;
490458 }
491459 }
492460 } ) ;
0 commit comments