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

[BUG] Badger blockstore is not safe if closed while in use #5795

Open
Stebalien opened this issue Mar 12, 2021 · 1 comment
Open

[BUG] Badger blockstore is not safe if closed while in use #5795

Stebalien opened this issue Mar 12, 2021 · 1 comment
Assignees
Labels
kind/bug Kind: Bug

Comments

@Stebalien
Copy link
Member

The badger blockstore has a state field to record whether or not the badger database is closed. Unfortunately, either:

  1. There's no way the blockstore will be closed concurrently with other operations. In this case, there's no need for the field to be atomic.
  2. The blockstore can be concurrently closed with other operations. In this case, the atomic is insufficient as we may:
    1. Thread A: See that the database is open.
    2. Thread B: Close the database.
    3. Thread A: Use the database. Badger likes to panic in this case.

Unless we have a really good reason not to, we should just use a RWMutex (like we do in go-ds-badger). If we do have a really good reason, we should figure out what we actually need here.

@shuang-x-zhao-qq
Copy link

Hello,i want to check with you guys whether we have a fix of this concurrent blockstore writing problem, i think our lotus client met this problem when we synced data, like below:

2023-04-09T06:56:58.022+0800 ERROR chainstore store/coalescer.go:213 error dispatching coalesced head change notification: 5 errors occurred:
* failed to get messages for apply block bafy2bzaceao7v562xmw3bwott6mol4tkyl64zgk7ebgqqzfjiaeoogovgfq6o(height 2756273) (msgroot = bafy2bzaceckjcg2a6pkxrd4imr4f4tlglze7stuxgeqi7h3sdhgu3xxj3d6hi): loading bls messages for block: failed to get message: (bafy2bzacecbux57urk4ee27u7qmz4a4cvbmq565ivdecposjy7q62r2x7gdxs):0: badger blockstore closed
* failed to get messages for apply block bafy2bzaced6ikf7j265zwshfcgyrcg3xcfdlgzxedk7ctwhvp7ahx5sqp5yda(height 2756273) (msgroot = bafy2bzacedpinp5puthe6ni52oigpwl6rd5s6ma4xq7626do4imx7d7dqfbly): loading bls messages for block: failed to get message: (bafy2bzacecbux57urk4ee27u7qmz4a4cvbmq565ivdecposjy7q62r2x7gdxs):0: badger blockstore closed
* failed to get messages for apply block bafy2bzacedmlgxxpkjlvpaoaieqrfspluzoxgacsplv3z6opr5s3v23c2haty(height 2756273) (msgroot = bafy2bzacebh4ztqxyemqualqk23zppjp6h5zptkzm7ipir3kvvmw7boiaxsxu): loading bls messages for block: failed to get message: (bafy2bzacecbux57urk4ee27u7qmz4a4cvbmq565ivdecposjy7q62r2x7gdxs):0: badger blockstore closed
* failed to get messages for apply block bafy2bzacediznucqqmb6o3lizk5tia27hwa5zvdeggnv7w5lwlsgfj4tl2abk(height 2756273) (msgroot = bafy2bzaceaccq5t7zzy5wqeddgfrdkshf45yvsndonkc7n2jhcrrnsa7iezkw): loading bls messages for block: failed to get message: (bafy2bzacea4jakq4s5v4iaqlrvvp5rxmnd6bt2v5lrjmm76jy5dblwmlcezv2):0: badger blockstore closed
* failed to get messages for apply block bafy2bzacecjpu5cb3iocwmvd3r44r3jihzotd67f4gnrjyhvkkzbtilvkzseo(height 2756273) (msgroot = bafy2bzacebo6ujqxnrorakn5g6hiag6mdpgbjhe2mbqv323gs7re632hznsou): loading bls messages for block: failed to get message: (bafy2bzaceakgbe3o6in3sqzqoxikza3ylgixkii5o3ws47y4ktpbmlb6b6g7s):0: badger blockstore closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Kind: Bug
Projects
None yet
Development

No branches or pull requests

4 participants