From 42c512547b4408afc0e1a86eef83364742bfd2c9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:39:06 -0500 Subject: [PATCH] v1.18: Purges all bank snapshots after fastboot (backport of #35350) (#35379) Purges all bank snapshots after fastboot (#35350) (cherry picked from commit bdc5cceb183c99e3d3c471af3ece2a2f7f7978d5) Co-authored-by: Brooks --- ledger/src/bank_forks_utils.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index 993f6d2c2f7645..7d174e9bbb2bf4 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -342,6 +342,15 @@ fn bank_forks_from_snapshot( source: err, path: bank_snapshot.snapshot_path(), })?; + + // If the node crashes before taking the next bank snapshot, the next startup will attempt + // to load from the same bank snapshot again. And if `shrink` has run, the account storage + // files that are hard linked in bank snapshot will be *different* than what the bank + // snapshot expects. This would cause the node to crash again. To prevent that, purge all + // the bank snapshots here. In the above scenario, this will cause the node to load from a + // snapshot archive next time, which is safe. + snapshot_utils::purge_old_bank_snapshots(&snapshot_config.bank_snapshots_dir, 0, None); + bank };