Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Block Storage] Always flush block and undo when switching to new file #2328

Merged
merged 2 commits into from
Apr 24, 2021

Conversation

furszy
Copy link

@furszy furszy commented Apr 21, 2021

Fixing a possible blocks db corruption cause.

Previously, the undo weren't being flushed during a reindex because
fKnown was set to true in FindBlockPos. That is the correct behaviour
for block files as they aren't being touched, but undo files are
touched.

This changes the behavior to always flush when switching to a new file
(even for block files, though that isn't really necessary).

Coming from bitcoin#6948.

Previously, the undo weren't being flushed during a reindex because
fKnown was set to true in FindBlockPos. That is the correct behaviour
for block files as they aren't being touched, but undo files are
touched.

This changes the behaviour to always flush when switching to a new file
(even for block files, though that isn't really necessary).
@furszy furszy self-assigned this Apr 21, 2021
@furszy furszy added this to the 6.0.0 milestone Apr 21, 2021
@random-zebra
Copy link

Nice. Would be good to include bitcoin#7023 here, to remove the warning.

@furszy
Copy link
Author

furszy commented Apr 23, 2021

Added 7023 per feedback. Compiler warning removed.

@furszy furszy force-pushed the 2021_undo_blocks_corruption_cause branch from bf6a491 to ab4f184 Compare April 23, 2021 13:55
Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

utACK ab4f184

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK ab4f184

@furszy furszy merged commit 22872bb into PIVX-Project:master Apr 24, 2021
furszy added a commit that referenced this pull request May 15, 2021
…tem.h

3e48fc1 Renamed and moved util.h/cpp files to util/system.h & util/system.cpp (furszy)
7954cef Style cleanup. (Jim Posen)
48801a9 Use common SetDataDir method to create temp directory in tests. (winder)
06464d3 flatfile: Unit tests for FlatFileSeq methods. (Jim Posen)
bbb9a90 scripted-diff: Rename CBlockDiskPos to FlatFilePos. (Jim Posen)
472857a Move CDiskBlockPos from chain to flatfile. (Jim Posen)
7fa47bb validation: Refactor file flush logic into FlatFileSeq. (Jim Posen)
bf09076 validation: Refactor block file pre-allocation into FlatFileSeq. (Jim Posen)
c813080 validation: Refactor OpenDiskFile into method on FlatFileSeq. (Jim Posen)
2619fe8 validation: Extract basic block file logic into FlatFileSeq class. (Jim Posen)
e65acf0 util: Move CheckDiskSpace to util. (Jim Posen)

Pull request description:

  This is part of the block logic refactoring and encapsulation work coming from upstream (work started in #2326 and #2328 due the possible blocks db corruption issue).
  Needed for two future works: (1) faster block validation using a new cache structure and (2) the future possible custom BIP157 (new sync protocol that supersedes BIP37 for light clients -- pending research needed after finishing v6.0 priorities --)

  Essentially, it's encapsulating the sequenced files open/read/write functionalities inside a new `flatfile` module,  and extending the unit test coverage to validate its correct behavior.

  Adapted the following PRs:

  * bitcoin#15118.
  * bitcoin#13145.
  * Plus added `util.h/cpp` files mv to `util/system.h` & `util/system.cpp`.

ACKs for top commit:
  random-zebra:
    utACK 3e48fc1

Tree-SHA512: c21ffb6ede054a279f9792c1cbe645b948078bd6bc607d32438f0601fd4df3650c0a34b349e46b4ea69b48f9e6c7bb18d258e139c6e1a47452ac9ea4f3bbee25
@furszy furszy changed the title Always flush block and undo when switching to new file [Block Storage] Always flush block and undo when switching to new file Aug 17, 2021
@furszy furszy deleted the 2021_undo_blocks_corruption_cause branch May 27, 2023 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants