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

removeElement panics with nil interface conversion #100

Closed
limhyesook opened this issue Apr 22, 2022 · 2 comments
Closed

removeElement panics with nil interface conversion #100

limhyesook opened this issue Apr 22, 2022 · 2 comments

Comments

@limhyesook
Copy link

Hello, I'm facing intermittent issues with using simplelru under high load. Here is the error:

Apr 22 05:56:59 server1 erigon[4187823]: panic: interface conversion: interface {} is nil, not *simplelru.entry
Apr 22 05:56:59 server1 erigon[4187823]: goroutine 355 [running]:
Apr 22 05:56:59 server1 erigon[4187823]: github.com/hashicorp/golang-lru/simplelru.(*LRU).removeElement(0x16ec740, 0xc0009cb608)
Apr 22 05:56:59 server1 erigon[4187823]: github.com/hashicorp/golang-lru@v0.5.5-0.20210104140557-80c98217689d/simplelru/lru.go:172 +0x107
Apr 22 05:56:59 server1 erigon[4187823]: github.com/hashicorp/golang-lru/simplelru.(*LRU).removeOldest(0x15d7080)
Apr 22 05:56:59 server1 erigon[4187823]: github.com/hashicorp/golang-lru@v0.5.5-0.20210104140557-80c98217689d/simplelru/lru.go:165 +0x34
Apr 22 05:56:59 server1 erigon[4187823]: github.com/hashicorp/golang-lru/simplelru.(*LRU).Add(0xc0036d5b60, {0x1567300, 0xc01e20ee10}, {0x15ad680, 0x371f460})
Apr 22 05:56:59 server1 erigon[4187823]: github.com/hashicorp/golang-lru@v0.5.5-0.20210104140557-80c98217689d/simplelru/lru.go:67 +0x394
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib/txpool.(*TxPool).discardLocked(0xc000200180, 0xc012f77ef0, 0x4)
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib@v0.0.0-20220401025652-224f0c9dc058/txpool/pool.go:1063 +0x15a
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib/txpool.(*TxPool).addLocked(0xc000200180, 0xc01c355a90)
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib@v0.0.0-20220401025652-224f0c9dc058/txpool/pool.go:1038 +0x2c5
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib/txpool.addTxs(0x105cc63, {0x28a5fe8, 0xc01e015938}, 0xc001c65a70, {{0xc010ff5800, 0x42, 0x80}, {0xc0153eec00, 0x528, 0x600}, ...}, ...)
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib@v0.0.0-20220401025652-224f0c9dc058/txpool/pool.go:905 +0x4a4
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib/txpool.(*TxPool).processRemoteTxs(0xc000200180, {0x28c2d58, 0xc0010eb480})
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib@v0.0.0-20220401025652-224f0c9dc058/txpool/pool.go:507 +0x4bc
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib/txpool.MainLoop({0x28c2d58, 0xc0010eb480}, {0x28cc1a8, 0xc001d92280}, {0x1ad4ccb667b585ab, 0x13748a941b4512d3}, 0xc000200180, 0xc0006ae780, 0xc0003571c0, 0xc0005ba150, ...)
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon-lib@v0.0.0-20220401025652-224f0c9dc058/txpool/pool.go:1327 +0x565
Apr 22 05:56:59 server1 erigon[4187823]: created by github.com/ledgerwatch/erigon/eth.New
Apr 22 05:56:59 server1 erigon[4187823]: github.com/ledgerwatch/erigon/eth/backend.go:475 +0x3368

Panic happens at this line I believe:
kv := e.Value.(*entry)

Is it because I'm misusing library in some way?

@arrony135
Copy link

simplelru is not thread safe, please make sure to protect by lock when Add or Get

@AskAlexSharov
Copy link

can close this issue. yes, it was thread-safety thing on our side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants