-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blockstore: separate write and prune batches.
ChainDB and BlockStore are separate and committing to them is not really atomic, so we need to make sure the order operations can handle failure at any step. Previously blockstore writes and prunes would happen after the chaindb was written, but that could lead to the situation where the blockstore did not actually have a block but chaindb had the information. This PR separates write and prune batches for the blockstore, so we can try writing to blockstore first. In case writing to blockstore fails whole operation will get aborted. Nothing gets written into the chaindb, so the information is consistent. In case blockstore writes a block and then chaindb write fails, we just get extra data in the blockstore. But most of the time, the same block write will happen again (either main or alt chains). Pruning always happens after the chaindb was updated to avoid situation, where chaindb thinks the data is stored, but blockstore has removed it. If blockstore fails to prune after chaindb removed the information, worst case scenario (prune mode) we get a maxFileLength(128 MB by default) space wasted.
- Loading branch information
Showing
6 changed files
with
392 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.