Skip to content

Commit

Permalink
Skip shutdown format checks when skipping format upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Nov 29, 2023
1 parent 077b47d commit f73249f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions zebra-scan/src/storage/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
5 changes: 4 additions & 1 deletion zebra-state/src/service/finalized_state/zebra_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit f73249f

Please sign in to comment.