mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Add readonly transaction rollback check rule (#8682)
This commit is contained in:
parent
466031ab8f
commit
a0682088ab
@ -177,7 +177,7 @@ func (b *SimulatedBackend) emptyPendingBlock() {
|
||||
if b.pendingReaderTx != nil {
|
||||
b.pendingReaderTx.Rollback()
|
||||
}
|
||||
tx, err := b.m.DB.BeginRo(context.Background())
|
||||
tx, err := b.m.DB.BeginRo(context.Background()) //nolint:gocritic
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -122,11 +122,13 @@ func CompareAccountRange(logger log.Logger, erigonURL, gethURL, tmpDataDir, geth
|
||||
log.Error(err.Error())
|
||||
return
|
||||
}
|
||||
defer tgTx.Rollback()
|
||||
gethTx, err := gethKV.BeginRo(context.Background())
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
return
|
||||
}
|
||||
defer gethTx.Rollback()
|
||||
tgCursor, err := tgTx.Cursor(kv.E2AccountsHistory)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
|
@ -105,7 +105,7 @@ func (db *DB) Agg() *state.AggregatorV3 { return db.agg }
|
||||
func (db *DB) InternalDB() kv.RwDB { return db.RwDB }
|
||||
|
||||
func (db *DB) BeginTemporalRo(ctx context.Context) (kv.TemporalTx, error) {
|
||||
kvTx, err := db.RwDB.BeginRo(ctx)
|
||||
kvTx, err := db.RwDB.BeginRo(ctx) //nolint:gocritic
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ func txDeferRollback(m dsl.Matcher) {
|
||||
`$tx, $err = $db.BeginRw($ctx); $chk; $rollback`,
|
||||
`$tx, $err := $db.Begin($ctx); $chk; $rollback`,
|
||||
`$tx, $err = $db.Begin($ctx); $chk; $rollback`,
|
||||
`$tx, $err := $db.BeginRo($ctx); $chk; $rollback`,
|
||||
`$tx, $err = $db.BeginRo($ctx); $chk; $rollback`,
|
||||
).
|
||||
Where(!m["rollback"].Text.Matches(`defer .*\.Rollback()`)).
|
||||
//At(m["rollback"]).
|
||||
|
2
rules.go
2
rules.go
@ -33,6 +33,8 @@ func txDeferRollback(m dsl.Matcher) {
|
||||
`$tx, $err = $db.BeginRw($ctx); $chk; $rollback`,
|
||||
`$tx, $err := $db.Begin($ctx); $chk; $rollback`,
|
||||
`$tx, $err = $db.Begin($ctx); $chk; $rollback`,
|
||||
`$tx, $err := $db.BeginRo($ctx); $chk; $rollback`,
|
||||
`$tx, $err = $db.BeginRo($ctx); $chk; $rollback`,
|
||||
).
|
||||
Where(!m["rollback"].Text.Matches(`defer .*\.Rollback()`)).
|
||||
//At(m["rollback"]).
|
||||
|
@ -14,6 +14,7 @@ func (api *ErigonImpl) CacheCheck() (*kvcache.CacheValidationResult, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
result, err := cache.ValidateCurrentRoot(ctx, tx)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user