From bba152656ccfdd1bdad4952d76d0aab955ba76ad Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 8 Aug 2023 13:57:05 +1000 Subject: [PATCH] Fix deadlock in finalization migration (#4576) --- beacon_node/beacon_chain/src/migrate.rs | 52 +++++-------------------- 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 50a39ac3839..93eb6f08724 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -163,11 +163,7 @@ impl, Cold: ItemStore> BackgroundMigrator, Cold: ItemStore> BackgroundMigrator, Cold: ItemStore> BackgroundMigrator, Cold: ItemStore> BackgroundMigrator { debug!( log, - "Database migration postponed, unaligned finalized block"; + "Database migration postponed due to unaligned finalized block"; "slot" => slot.as_u64() ); } @@ -379,10 +372,14 @@ impl, Cold: ItemStore> BackgroundMigrator format!("{:?}", e)); + warn!(log, "Database compaction failed"; "error" => ?e); } - debug!(log, "Database consolidation complete"); + debug!( + log, + "Database consolidation complete"; + "running_time_ms" => timer.elapsed().as_millis() + ); } /// Spawn a new child thread to run the migration process. @@ -390,7 +387,6 @@ impl, Cold: ItemStore> BackgroundMigrator>, - prev_migration: Arc>, log: Logger, ) -> ( crossbeam_channel::Sender, @@ -458,35 +454,7 @@ impl, Cold: ItemStore> BackgroundMigrator prev_migration.epoch, - "new_finalized_epoch" => epoch, - "epochs_per_migration" => prev_migration.epochs_per_migration, - ); - continue; - } - - // We intend to run at this epoch, update the in-memory record of the last epoch - // at which we ran. This value isn't tracked on disk so we will always migrate - // on the first finalization after startup. - prev_migration.epoch = epoch; - Self::run_migration(db.clone(), notif.to_owned(), &log); - - info!( - log, - "Finished finalization migration"; - "running_time_ms" => timer.elapsed().as_millis() - ); } } });