dgraph-io / badger

Fast key-value DB in Go.

Home Page:https://dgraph.io/badger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: panic: runtime error: index out of range [3] with length 0 [recovered]

jonathanhecl opened this issue · comments

What version of Badger are you using?

v3.2103.5

What version of Go are you using?

1.17

Have you tried reproducing the issue with the latest release?

None

What is the hardware spec (RAM, CPU, OS)?

VPN

What steps will reproduce the bug?

My code

``
opt := badger.DefaultOptions("mydata.db")
opt.WithIndexCacheSize(80 << 20)
opt.WithValueLogFileSize(10 << 20)
opt.CompactL0OnClose = true
opt.Logger = nil

db, err = badger.Open(opt)
if err != nil {
	log.Fatal(err)
}
``

Expected behavior and actual result.

Error message:


panic: runtime error: index out of range [3] with length 0 [recovered]
        panic:
== Recovering from initIndex crash ==
File Info: [ID: 42, Size: 771450, Zeros: 771450]
isEnrypted: false checksumLen: 0 checksum:  indexLen: 0 index: []
== Recovered ==


goroutine 28 [running]:
github.com/dgraph-io/badger/v3/table.(*Table).initBiggestAndSmallest.func1.1()
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/table/table.go:351 +0xa8
github.com/dgraph-io/badger/v3/table.(*Table).initBiggestAndSmallest.func1()
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/table/table.go:397 +0xc2
panic({0x1123040, 0xc0003900a8})
        C:/Program Files/Go/src/runtime/panic.go:884 +0x212
github.com/google/flatbuffers/go.GetUint32(...)
        C:/Users/GS/go/pkg/mod/github.com/google/flatbuffers@v23.5.9+incompatible/go/encode.go:47
github.com/google/flatbuffers/go.GetUOffsetT(...)
        C:/Users/GS/go/pkg/mod/github.com/google/flatbuffers@v23.5.9+incompatible/go/encode.go:121
github.com/dgraph-io/badger/v3/fb.GetRootAsTableIndex(...)
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/fb/TableIndex.go:14
github.com/dgraph-io/badger/v3/table.(*Table).readTableIndex(0xc00039e0c0)
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/table/table.go:707 +0x15e
github.com/dgraph-io/badger/v3/table.(*Table).initIndex(0xc00039e0c0)
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/table/table.go:462 +0x19d
github.com/dgraph-io/badger/v3/table.(*Table).initBiggestAndSmallest(0xc00039e0c0)
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/table/table.go:401 +0x7f
github.com/dgraph-io/badger/v3/table.OpenTable(0xc00045a1e0, {0x0, 0x1, 0x200000, 0x0, 0x0, 0x3f847ae147ae147b, 0x1000, 0x0, 0x1, ...})
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/table/table.go:308 +0x272
github.com/dgraph-io/badger/v3.newLevelsController.func1({0xc000390090, 0x15}, {0x0?, 0x0?, 0x0?})
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/levels.go:150 +0x1f9
created by github.com/dgraph-io/badger/v3.newLevelsController
        C:/Users/GS/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/levels.go:129 +0x585
exit status 2

Additional information

I use the same source working by month adding data without problem.
Now, I can't start the app.

Are you on windows by any chance? This seems related to #1883

Yes, the VPN is with Windows.

I believe is the same #1883