-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix badger double open on daemon --import-snapshot; chainstore lifecycle #4872
Conversation
@@ -383,7 +382,7 @@ func (cs *ChainStore) MaybeTakeHeavierTipSet(ctx context.Context, ts *types.TipS | |||
// particular tipset to carry out a benchmark, verification, etc. on a chain | |||
// segment. | |||
func (cs *ChainStore) ForceHeadSilent(_ context.Context, ts *types.TipSet) error { | |||
log.Warnf("(!!!) forcing a new head silently; only use this only for testing; new head: %s", ts) |
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.
eh?
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.
?
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.
There was no valid use for this outside testing before. When importing snapshot it doesn't make sense to emit reorg notifications as nothing is listening on that chainstore, and everything that cares about chain state does check current state when subscribing
tldr this is fine
Personally I would prefer if chainstore had a Close method instead of relying on the context for the lifetime. |
aec4fdf
to
0c6072a
Compare
@magik6k wanna merge this? |
…fix-blockstore-import fix badger double open on daemon --import-snapshot; chainstore lifecycle
This PR fixes #4850. The problem was that the IdStore did not implement
io.Closer
, therefore the store remained open after the import. This required a release of go-ipfs-blockstore, which has now been integrated here.I also noticed this error (which I think has been there since forever; EDIT: confirmed, this was already there! #4428) just after the import is done, and before we start the node:
This happens because the
SetHead
insideImportChain
triggers a reorg, but by the team the event arrives to the event loop, the badger store is closed. There are two problems here:reorgWorker
after snapshot import #4428.SetHead
should not trigger a reorg; we can use the newly-addedForceHeadSilent
operation to set the head without a reorg.This PR fixes both those things too.