Page MenuHomePhabricator

prune: scan and unlink already pruned block files on startup
ClosedPublic

Authored by PiRK on May 3 2024, 09:32.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.May 3 2024, 09:32

nit: make file permission and shebang conistent with other functional tests

Fabien requested changes to this revision.May 3 2024, 11:56
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/node/blockstorage.cpp
581 ↗(On Diff #47593)

please use a better name here, ec usually stands for elliptic crypto in our codebase

This revision now requires changes to proceed.May 3 2024, 11:56
This revision is now accepted and ready to land.May 6 2024, 07:27