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

Fix repo close typed nil issue #4921

Closed
wants to merge 1 commit into from
Closed

Fix repo close typed nil issue #4921

wants to merge 1 commit into from

Conversation

Kubuxu
Copy link
Contributor

@Kubuxu Kubuxu commented Nov 19, 2020

Manifests when while trying to run import-chain, the Blockstore fails to
open.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1004a42]goroutine 1 [running]:
github.com/filecoin-project/lotus/lib/blockstore/badger.(*Blockstore).Close(0x0, 0x0, 0x0)
	/root/go/src/github.com/lotus/lib/blockstore/badger/blockstore.go:129 +0x42
github.com/ipfs/go-ipfs-blockstore.(*idstore).Close(0xc0019eb380, 0x331bb60, 0xc0019eb380)
	/root/go/pkg/mod/github.com/ipfs/[email protected]/idstore.go:120 +0x62
github.com/filecoin-project/lotus/node/repo.(*fsLockedRepo).Close(0xc000d9c0b0, 0x20, 0x2e100c0)
	/root/go/src/github.com/lotus/node/repo/fsrepo.go:291 +0x2a2
main.ImportChain(0x32f6bc0, 0xc0004fffa0, 0x7ffcc6f436cb, 0x64, 0x1, 0x32c9a60, 0xc0023e00c0)
	/root/go/src/github.com/lotus/cmd/lotus/daemon.go:410 +0x2f0
main.glob..func3(0xc0004f7000, 0x0, 0x0)
	/root/go/src/github.com/lotus/cmd/lotus/daemon.go:230 +0x8c8
github.com/urfave/cli/v2.(*App).RunAsSubcommand(0xc000093b00, 0xc0004f6b40, 0x0, 0x0)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:432 +0x9bf
github.com/urfave/cli/v2.(*Command).startApp(0x593c1c0, 0xc0004f6b40, 0x2e7e8e9, 0x7ffcc6f436b2)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:279 +0x6bb
github.com/urfave/cli/v2.(*Command).Run(0x593c1c0, 0xc0004f6b40, 0x0, 0x0)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:94 +0x9cd
github.com/urfave/cli/v2.(*App).RunContext(0xc000093980, 0x33052c0, 0xc0000be000, 0xc0000d2000, 0x4, 0x4, 0x0, 0x0)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:306 +0x81f
github.com/urfave/cli/v2.(*App).Run(...)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:215
github.com/filecoin-project/lotus/cli.RunApp(0xc000093980)
	/root/go/src/github.com/lotus/cli/helper.go:35 +0x7c
main.main()
	/root/go/src/github.com/lotus/cmd/lotus/main.go:74 +0x645

Manifests when while trying to run import-chain, the Blockstore fails to
open.

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1004a42]goroutine 1 [running]:
github.com/filecoin-project/lotus/lib/blockstore/badger.(*Blockstore).Close(0x0, 0x0, 0x0)
	/root/go/src/github.com/lotus/lib/blockstore/badger/blockstore.go:129 +0x42
github.com/ipfs/go-ipfs-blockstore.(*idstore).Close(0xc0019eb380, 0x331bb60, 0xc0019eb380)
	/root/go/pkg/mod/github.com/ipfs/[email protected]/idstore.go:120 +0x62
github.com/filecoin-project/lotus/node/repo.(*fsLockedRepo).Close(0xc000d9c0b0, 0x20, 0x2e100c0)
	/root/go/src/github.com/lotus/node/repo/fsrepo.go:291 +0x2a2
main.ImportChain(0x32f6bc0, 0xc0004fffa0, 0x7ffcc6f436cb, 0x64, 0x1, 0x32c9a60, 0xc0023e00c0)
	/root/go/src/github.com/lotus/cmd/lotus/daemon.go:410 +0x2f0
main.glob..func3(0xc0004f7000, 0x0, 0x0)
	/root/go/src/github.com/lotus/cmd/lotus/daemon.go:230 +0x8c8
github.com/urfave/cli/v2.(*App).RunAsSubcommand(0xc000093b00, 0xc0004f6b40, 0x0, 0x0)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:432 +0x9bf
github.com/urfave/cli/v2.(*Command).startApp(0x593c1c0, 0xc0004f6b40, 0x2e7e8e9, 0x7ffcc6f436b2)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:279 +0x6bb
github.com/urfave/cli/v2.(*Command).Run(0x593c1c0, 0xc0004f6b40, 0x0, 0x0)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:94 +0x9cd
github.com/urfave/cli/v2.(*App).RunContext(0xc000093980, 0x33052c0, 0xc0000be000, 0xc0000d2000, 0x4, 0x4, 0x0, 0x0)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:306 +0x81f
github.com/urfave/cli/v2.(*App).Run(...)
	/root/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:215
github.com/filecoin-project/lotus/cli.RunApp(0xc000093980)
	/root/go/src/github.com/lotus/cli/helper.go:35 +0x7c
main.main()
	/root/go/src/github.com/lotus/cmd/lotus/main.go:74 +0x645
```

Signed-off-by: Jakub Sztandera <[email protected]>
@raulk
Copy link
Member

raulk commented Nov 19, 2020

Almost right, but this isn't the problem. The problem is that the import was done on a brand new node that had no associated repo/datastore yet, i.e. the chain directory didn't exist. I introduced a regression where I don't create the directory any longer, therefore badger fails to open. Unfortunately, there's a return missing here, so we end up wrapping a nil store with IDStore, which does implement Closer. Therefore, this PR will not solve this problem, because fs.bs is non-nil.

lotus/node/repo/fsrepo.go

Lines 317 to 320 in 7be7a9b

bs, err := badgerbs.Open(opts)
if err != nil {
fsr.bsErr = err
}

I'll submit a PR in a few mins.

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

Successfully merging this pull request may close these issues.

2 participants