Skip to content

Crash on decoding value using CLI #1399

@ammmir

Description

@ammmir

What version of Go are you using (go version)?

$ go version
go version go1.14.3 darwin/amd64

What operating system are you using?

MacOS X

What version of Badger are you using?

2.0.3

Does this issue reproduce with the latest master?

Not tested

What Badger options were set?

default

What did you do?

Database was migrated from manifest v4 to v7 (badger 1.6.0 or thereabouts to 2.0.3) via badger backup/restore.

badger info --dir db --show-keys --with-prefix 019a4730021f457ba087a255a58f49 --read-only=false

What did you see instead?

╰─➤  /tmp/badger2 info --dir db --show-keys --with-prefix 019a4730021f457ba087a255a58f49 --read-only=false
Listening for /debug HTTP requests at port: 8080

[2020-07-08T15:58:40+09:00] MANIFEST       50 B MA
[        6 minutes earlier] 000008.sst    15 MB L1
[       40 minutes earlier] 000000.vlog   96 MB VL
[       40 minutes earlier] 000002.vlog  1.3 GB VL
[                      now] 000003.vlog   32 MB VL

[EXTRA]
[2020-07-08T15:18:08+09:00] KEYREGISTRY    28 B

[Summary]
Level 0 size:          0 B
Level 1 size:        15 MB
Total index size:    15 MB
Value log size:     1.4 GB

Abnormalities:
1 extra file.
0 missing files.
0 empty files.
0 truncated manifests.
badger 2020/07/08 15:58:42 INFO: All 1 tables opened in 10ms
badger 2020/07/08 15:58:42 INFO: Replaying file id: 3 at offset: 32266481
badger 2020/07/08 15:58:42 INFO: Replay took: 5.337µs
badger 2020/07/08 15:58:42 DEBUG: Value log discard stats empty
Only choosing keys with prefix:
00000000  01 9a 47 30 02 1f 45 7b  a0 87 a2 55 a5 8f 49     |..G0..E{...U..I|
badger 2020/07/08 15:58:42 INFO: Got compaction priority: {level:0 score:1.73 dropPrefix:[]}
panic: runtime error: slice bounds out of range [:12] with capacity 0

goroutine 1 [running]:
github.com/dgraph-io/badger/v2.(*valuePointer).Decode(...)
	/Users/amir/src/badger/structs.go:61
github.com/dgraph-io/badger/v2.(*Item).EstimatedSize(...)
	/Users/amir/src/badger/iterator.go:247
github.com/dgraph-io/badger/v2/badger/cmd.printKey(0xc00019c6e0, 0xc0001b0000, 0x10, 0x10)
	/Users/amir/src/badger/badger/cmd/info.go:211 +0x61c
github.com/dgraph-io/badger/v2/badger/cmd.showKeys(0xc000330000, 0xc0000c8100, 0xf, 0x20, 0x0, 0x0)
	/Users/amir/src/badger/badger/cmd/info.go:151 +0x257
github.com/dgraph-io/badger/v2/badger/cmd.handleInfo(0x4aa0840, 0xc0001888a0, 0x0, 0x6, 0x0, 0x0)
	/Users/amir/src/badger/badger/cmd/info.go:120 +0x4ce
github.com/spf13/cobra.(*Command).execute(0x4aa0840, 0xc000188840, 0x6, 0x6, 0x4aa0840, 0xc000188840)
	/Users/amir/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x4aa0fc0, 0x403aee0, 0x4a5c728, 0x0)
	/Users/amir/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/amir/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/dgraph-io/badger/v2/badger/cmd.Execute()
	/Users/amir/src/badger/badger/cmd/root.go:40 +0x31
main.main()
	/Users/amir/src/badger/badger/main.go:41 +0x54

If --with-prefix is omitted it doesn't crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/needs-specsIssues that require further specification before implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions