Skip to content
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

Add a lock to fix the panic while starting and loading the pool db. #920

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

zjg555543
Copy link

@zjg555543 zjg555543 commented Aug 6, 2024

It got a panic while pool had many tx and restart node agagin.
Error is concurrent map read and map write, at the code p.isLocalLRU.Add(string(v), struct{}{})

  1. first goroutine
github.com/hashicorp/golang-lru/v2/simplelru.(*LRU[...]).Add() 
github.com/ledgerwatch/erigon/zk/txpool.(*TxPool).fromDB()
github.com/ledgerwatch/erigon/zk/txpool.(*TxPool).OnNewBlock()
  1. second goroutine
github.com/ledgerwatch/erigon/zk/txpool.(*TxPool).fromDB()
github.com/ledgerwatch/erigon/zk/txpool.(*TxPool).StartIfNotStarted

So, use a lock here when loading the pool.

@cla-bot cla-bot bot added the cla-signed label Aug 6, 2024
Copy link

sonarqubecloud bot commented Aug 8, 2024

@mandrigin mandrigin enabled auto-merge (squash) August 12, 2024 11:50
@mandrigin mandrigin merged commit f3ba2f7 into 0xPolygonHermez:zkevm Aug 12, 2024
4 of 5 checks passed
@zjg555543 zjg555543 deleted the zjg/fix-load-pool branch December 24, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants