-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[to discuss] exec blocks without ObjectDb: Mutation over TxDb #947
Conversation
AskAlexSharov
commented
Aug 20, 2020
- Usage of TxDb means don't open read transaction every time you wanna read something from db.
- On fast disk it speeding genesis sync 21hour -> 17hours
- But it a bit increases complexity of stage_exec - now there is db.Begin, then tx.NewBatch, then both of them need periodical commit
- I need your advise - maybe we can simplify code somehow?
I don't see it as a big increase in complexity at all. Will test the full sync with it myself soon |
@@ -132,6 +147,9 @@ func SpawnExecuteBlocksStage(s *StageState, stateDB ethdb.Database, chainConfig | |||
if _, err := batch.Commit(); err != nil { | |||
return fmt.Errorf("sync Execute: failed to write batch commit: %v", err) | |||
} | |||
if _, err = tx.Commit(); err != nil { |
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.
what will happen when we Commit and the defer calls Rollback?
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.
Commit sets internal transaction object to nil, then rollback do something only if that object is not nil. So, rollback after commit must not do anything. Same for double-rollback.
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.
With Tx need to be more strict than with mutation: if tx not closed well - it can cause deadlock or leak.