Adds comments in BankSnapshotInfo::new_from_dir() when selecting Pre or Post (#32261)

This commit is contained in:
Brooks 2023-06-26 11:53:25 -04:00 committed by GitHub
parent 4fb6bbf92e
commit 644cdaaa48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -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() {