From 644cdaaa48d15c56c527af047ceb790c641c4b72 Mon Sep 17 00:00:00 2001 From: Brooks Date: Mon, 26 Jun 2023 11:53:25 -0400 Subject: [PATCH] Adds comments in BankSnapshotInfo::new_from_dir() when selecting Pre or Post (#32261) --- runtime/src/snapshot_utils.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 7937f1df7b..cca8b86835 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -213,6 +213,14 @@ impl BankSnapshotInfo { let bank_snapshot_pre_path = bank_snapshot_post_path.with_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); + // NOTE: It is important that checking for "Pre" happens before "Post. + // + // Consider the scenario where AccountsHashVerifier is actively processing an + // AccountsPackage for a snapshot/slot; if AHV is in the middle of reserializing the + // bank snapshot file (writing the new "Post" file), and then the process dies, + // there will be an incomplete "Post" file on disk. We do not want only the existence of + // this "Post" file to be sufficient for deciding the snapshot type as "Post". More so, + // "Post" *requires* the *absence* of a "Pre" file. let snapshot_type = if bank_snapshot_pre_path.is_file() { BankSnapshotType::Pre } else if bank_snapshot_post_path.is_file() {