Badger Run time error : Slice out of bound range

52 Views Asked by At

I am getting this error while running my process for badger. The error is not in process. Its with in badger library.

    panic: runtime error: slice bounds out of range [-4169358568:] [recovered]
        panic: runtime error: slice bounds out of range [-4169358568:]
        panic: 
    == Recovering from initIndex crash ==
    File Info: [ID: 95, Size: 69121215, Zeros: 0]
    isEnrypted: false checksumLen: 4238479779 
    == Recovered ==
    
    
    goroutine 6932842 [running]:
    github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest.func1.1()
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:353 +0xa8
    panic({0xba9420, 0xc4324db2d8})
        /usr/local/go/src/runtime/panic.go:884 +0x212
    github.com/dgraph-io/ristretto/z.(*MmapFile).Bytes(...)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/ristretto/z/file.go:116
    github.com/dgraph-io/badger/v4/table.(*Table).read(...)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:420
    github.com/dgraph-io/badger/v4/table.(*Table).readNoFail(0xd0a740?, 0xc4a7b68810?, 0xbfe74d?)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:424 +0xd0
    github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest.func1()
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:383 +0x2ff
    panic({0xba9420, 0xc4324db2c0})
        /usr/local/go/src/runtime/panic.go:884 +0x212
    github.com/dgraph-io/ristretto/z.(*MmapFile).Bytes(...)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/ristretto/z/file.go:116
    github.com/dgraph-io/badger/v4/table.(*Table).read(...)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:420
    github.com/dgraph-io/badger/v4/table.(*Table).readNoFail(0x6?, 0x0?, 0x9?)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:424 +0xd0
    github.com/dgraph-io/badger/v4/table.(*Table).initIndex(0xc47e194180)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:445 +0x109
    github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest(0xc47e194180)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:403 +0x7f
    github.com/dgraph-io/badger/v4/table.OpenTable(0xc31e8f4160, {0x0, 0x1, 0x1000000, 0xf33333, 0x0, 0x3f847ae147ae147b, 0x1000, 0x0, 0x1, ...})
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:309 +0x278
    github.com/dgraph-io/badger/v4/table.CreateTable({0xc167146b80, 0x33}, 0xccef5a4090)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/table/table.go:273 +0x305
    github.com/dgraph-io/badger/v4.(*levelsController).subcompact.func4(0xccef5a4090, 0xc025c8b6e0?)
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/levels.go:846 +0x11b
    created by github.com/dgraph-io/badger/v4.(*levelsController).subcompact
        /data/badger_broadband/badger_grpc/vendor/github.com/dgraph-io/badger/v4/levels.go:836 +0x707

Badger Version: 4.2.0 Golang version: 1.19

Badger Initialisation

 // func to create a key value db
func NewKeyValueDB(dataDir, name string) (*KeyValueDB, error) {
    opts := badger.DefaultOptions(dataDir + "/" + name)
    opts.InMemory = false
    opts.Compression =  options.None
    opts.NumCompactors = 2
    opts.NumGoroutines = 4
    opts.BlockCacheSize = 0
    db, err := badger.Open(opts)
    if err != nil {
        return nil, err
    }
    return &KeyValueDB{
        DB:      db,
        dataDir: dataDir,
        name:    name,
    }, nil
}

The error is coming from the badger internal library, Follow the path in the error.

Even If I initialize the badger db like this

// func to create a key value db
func NewKeyValueDB(dataDir, name string) (*KeyValueDB, error) {
    opts := badger.DefaultOptions(dataDir + "/" + name)
    db, err := badger.Open(opts)
    if err != nil {
        return nil, err
    }
    return &KeyValueDB{
        DB:      db,
        dataDir: dataDir,
        name:    name,
    }, nil
}

I am getting the same error.

0

There are 0 best solutions below