Skip to content

Conversation

@aureleoules
Copy link
Contributor

@aureleoules aureleoules commented Oct 18, 2022

Attempt to fix #26112.

As suggested by sipa in #26112 (comment):

CCoinsViewErrorCatcher, the wrapper class used around CCoinsViewDB that's supposed to detect these problems and forcefully exit the application, has an override for GetCoins. But in CheckTxInputs, HaveInputs is first invoked, which on its turn calls HaveCoin. HaveCoin is implemented in CCoinsViewDB, but not in CCoinsViewErrorCatcher, and thus the disk read exception escapes.
A solution may be to just add an override for HaveCoin in CCoinsViewErrorCatcher.

I implemented CCoinsViewErrorCatcher::HaveCoin and also added a periodic disk space check that shutdowns the node if there is not enough space left on disk, the minimum here is 50MB.

For reviewers, it's possible to saturate disk space to test the PR by creating large files with fallocate -l 50G test.bin

@aureleoules aureleoules force-pushed the 2022-10-disk-space-problems-fix branch from 2c4d837 to 1527570 Compare October 18, 2022 14:24
@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 18, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK w0xlt, sipa, achow101

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK ed52e71

Copy link
Member

@sipa sipa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK ed52e71

@fanquake fanquake added this to the 26.0 milestone Sep 29, 2023
@fanquake
Copy link
Member

fanquake commented Oct 2, 2023

@willcl-ark you might have some thoughts on writing some sort of test for this?

@achow101
Copy link
Member

achow101 commented Oct 9, 2023

ACK ed52e71

@achow101 achow101 merged commit 04265ba into bitcoin:master Oct 9, 2023
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Oct 13, 2023
… check disk space periodically

ed52e71 Periodically check disk space to avoid corruption (Aurèle Oulès)
7fe537f Implement CCoinsViewErrorCatcher::HaveCoin (Aurèle Oulès)

Pull request description:

  Attempt to fix bitcoin#26112.

  As suggested by sipa in bitcoin#26112 (comment):
  > CCoinsViewErrorCatcher, the wrapper class used around CCoinsViewDB that's supposed to detect these problems and forcefully exit the application, has an override for GetCoins. But in CheckTxInputs, HaveInputs is first invoked, which on its turn calls HaveCoin. HaveCoin is implemented in CCoinsViewDB, but not in CCoinsViewErrorCatcher, and thus the disk read exception escapes.
  > A solution may be to just add an override for HaveCoin in CCoinsViewErrorCatcher.

  I implemented `CCoinsViewErrorCatcher::HaveCoin` and also added a periodic disk space check that shutdowns the node if there is not enough space left on disk, the minimum here is 50MB.

  For reviewers, it's possible to saturate disk space to test the PR by creating large files with `fallocate -l 50G test.bin`

ACKs for top commit:
  achow101:
    ACK ed52e71
  w0xlt:
    Code Review ACK bitcoin@ed52e71
  sipa:
    utACK ed52e71

Tree-SHA512: 456aa7b996023df42b4fbb5158ee429d9abf7374b7b1ec129b21aea1188ad19be8da4ae8e0edd90b85b7a3042b8e44e17d3742e33808a4234d5ddbe9bcef1b78
@jonatack
Copy link
Member

Post-merge concept ACK. Some kind of test coverage would be good.

@bitcoin bitcoin locked and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running out of disk space can leave bitcoin in a desynced state

7 participants