From f73249fe88fac2deb582b3ec9e68f5bd1311491d Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 29 Nov 2023 15:30:49 +1000 Subject: [PATCH] Skip shutdown format checks when skipping format upgrades --- zebra-scan/src/storage/db.rs | 2 ++ zebra-state/src/service/finalized_state/zebra_db.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zebra-scan/src/storage/db.rs b/zebra-scan/src/storage/db.rs index de5f83cbe5e..41f40f0c3b1 100644 --- a/zebra-scan/src/storage/db.rs +++ b/zebra-scan/src/storage/db.rs @@ -96,6 +96,8 @@ impl Storage { /// If a thread exited with a panic, resume that panic. /// /// This method should be called regularly, so that panics are detected as soon as possible. + // + // TODO: when we implement format changes, call this method regularly pub fn check_for_panics(&mut self) { self.db.check_for_panics() } diff --git a/zebra-state/src/service/finalized_state/zebra_db.rs b/zebra-state/src/service/finalized_state/zebra_db.rs index 155d19686aa..6229de1bca0 100644 --- a/zebra-state/src/service/finalized_state/zebra_db.rs +++ b/zebra-state/src/service/finalized_state/zebra_db.rs @@ -229,13 +229,16 @@ impl ZebraDb { /// /// See [`DiskDb::shutdown`] for details. pub fn shutdown(&mut self, force: bool) { + // Are we shutting down the underlying database instance? + let is_shutdown = force || self.db.shared_database_owners() <= 1; + // # Concurrency // // The format upgrade task should be cancelled before the database is flushed or shut down. // This helps avoid some kinds of deadlocks. // // See also the correctness note in `DiskDb::shutdown()`. - if force || self.db.shared_database_owners() <= 1 { + if !self.debug_skip_format_upgrades && is_shutdown { if let Some(format_change_handle) = self.format_change_handle.as_mut() { format_change_handle.force_cancel(); }