HomePhabricator

prune: scan and unlink already pruned block files on startup

Description

prune: scan and unlink already pruned block files on startup

Summary:
There are a few cases where we can mark a block and undo file as pruned in our block index, but not actually remove the files from disk.

  • If we call FindFilesToPrune or FindFilesToPruneManual and crash before UnlinkPrunedFiles.
  • If on Windows there is an open file handle to the file somewhere else when calling fs::remove in UnlinkPrunedFiles. This could be from another process, or if we are calling ReadBlockFromDisk/ReadRawBlockFromDisk without having a lock on cs_main (allowed since D2979).

This PR mitigates this by scanning all pruned block files on startup after LoadBlockIndexDB and unlinking them again.

This is a backport of core#26533

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D16102

Details

Provenance
Andrew Toth <andrewstoth@gmail.com>Authored on Dec 20 2022, 17:25
PiRKCommitted on May 6 2024, 11:53
PiRKPushed on May 6 2024, 11:53
Reviewer
Restricted Project
Differential Revision
D16102: prune: scan and unlink already pruned block files on startup
Parents
rABCd6f7cb05623c: [guix] Better SHA256SUMS format
Branches
Unknown
Tags
Unknown