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
Atomically persist blocks, headers, & tries #1279
Conversation
I decided it's better to just do this the right way, and get real levelDB transaction atomic commits. So this is still a WIP. |
db5f28d
to
0f42713
Compare
Wrapping up for the day. Last thing I'd want to do is detect and blow up if the |
0f42713
to
aa565dc
Compare
This is a little big. I'll peel it off into parts, starting with #1295 |
... and onto #1296 |
and #1304 -- which fixes some conceptual issues that will slightly change the approach in this PR: it will require that header and chain db can write to an explicitly provided database handle, instead of their internal |
aa565dc
to
ab0a310
Compare
Looks good to me 👍 It's a shame that our benchmark suite still entirely relies on the |
What was wrong?
We can end up with inconsistent state when shutting down trinity (say, a header persisted, but the canonical head not updated, or missing the transaction or uncle data, etc). This is because we persist all database writes immediately.
How was it fixed?
Persist batches of writes atomically.
This used to be one massive pull, which were peeled off into:
Now this PR just does final step: it uses the new
db.atomic_batch()
API to force all writes to atomically succeed (or fail) in three places:There are probably other places that would benefit from doing an atomic batch (both for performance and correctness reasons), but these were the lowest hanging fruit.
This introduced several shadow methods in the chain and header dbs, that accept a
BaseDB
as an argument, so we can pass in the atomic batch for writing. They were moved toclassmethod
so that no one accidentally adds a reference toself.db
going forward.Cute Animal Picture