-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
silkworm: recreate tx batch and disable read-ahead in block execution #9293
Conversation
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.
without defer rollback
you will have tx leak if panic happens inside silkworm.ExecuteBlocks
eth/stagedsync/stage_execute.go
Outdated
@@ -468,6 +468,16 @@ Loop: | |||
_, isMemoryMutation := txc.Tx.(*membatchwithdb.MemoryMutation) | |||
if cfg.silkworm != nil && !isMemoryMutation { | |||
blockNum, err = silkworm.ExecuteBlocks(cfg.silkworm, txc.Tx, cfg.chainConfig.ChainID, blockNum, to, uint64(cfg.batchSize), writeChangeSets, writeReceipts, writeCallTraces) | |||
// Recreate tx because Silkworm has just done commit or abort on passed one | |||
tx, tx_err := cfg.db.BeginRw(context.Background()) |
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.
-
probably you need
=
instead of:=
to assign on existingtx
variable (you doing it withbatch
). -
It's bad pattern: to open tx on one layer of abstraction and close/commit in another. In this case high-level code can't provide "committed all or nothing" guarantee.
Better: if tx was created on top-level - then it must be closed/commit only at top-level, if on low-level - then close/commit on low-level.
We already using both (seeuseExternalTx
variable) - but not mixing them.
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.
- OK, I'm going to change it in this PR
- OK, I'll do it in a separate PR
here you mean when |
No description provided.