-
Notifications
You must be signed in to change notification settings - Fork 738
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
Harden against IO failures using DB atomicity #1180
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ pub trait Store<E: EthSpec>: Sync + Send + Sized + 'static { | |
fn put_state(&self, state_root: &Hash256, state: &BeaconState<E>) -> Result<(), Error>; | ||
|
||
/// Execute either all of the operations in `batch` or none at all, returning an error. | ||
fn do_atomically(&self, batch: &[StoreOp]) -> Result<(), Error>; | ||
fn do_atomically(&self, batch: &[StoreOp<E>]) -> Result<(), Error>; | ||
|
||
/// Store a state summary in the store. | ||
// NOTE: this is a hack for the HotColdDb, we could consider splitting this | ||
|
@@ -185,7 +185,9 @@ pub trait Store<E: EthSpec>: Sync + Send + Sized + 'static { | |
|
||
/// Reified key-value storage operation. Helps in modifying the storage atomically. | ||
/// See also https://github.com/sigp/lighthouse/issues/692 | ||
pub enum StoreOp { | ||
pub enum StoreOp<'a, E: EthSpec> { | ||
PutBlock(SignedBeaconBlockHash, SignedBeaconBlock<E>), | ||
PutState(BeaconStateHash, &'a BeaconState<E>), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm on board with using a reference here, but with state summaries existing it might make sense to mix in the two variants from // Allow owned states for the storage of intermediate states in block processing (uncommon)
PutState(BeaconStateHash, Cow<'a, BeaconState<E>>),
PutStateSummary(BeaconStateHash, HotStateSummary), See https://github.com/sigp/lighthouse/blob/master/beacon_node/store/src/state_batch.rs
|
||
DeleteBlock(SignedBeaconBlockHash), | ||
DeleteState(BeaconStateHash, Slot), | ||
} | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State storage needs to take into account the
HotStateSummary
here, as in the non-atomic case:lighthouse/beacon_node/store/src/hot_cold_store.rs
Lines 372 to 398 in d79e079
The compositionality of the
HotColdDB
consisting of two sub-stores (hot_db
andcold_db
) with the same API is a lie, and is another reason why theStore
trait should be refactored IMO. I don't thinkStore
should be implemented forLevelDB
, because we never use just oneLevelDB
database as the store any more, and it creates awkwardness when aStore
API has to be implemented on the underlying store with assumptions about that API only getting used for the hot or cold DB (in this case we're assuming hot). I think it makes sense to put all this logic in the parent impl ofdo_atomically
(i.e.HotColdDB
), and stub out the impl forLevelDB
so that it returns an error.