提问人:Akhilesh mahajan 提问时间:9/20/2023 最后编辑:Akhilesh mahajan 更新时间:9/21/2023 访问量:33
Badger 运行时错误:切片超出界范围
Badger Run time error : Slice out of bound range
问:
我在运行 badger 进程时收到此错误。错误未在处理中。它在獾库中。
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
獾版本:4.2.0 Golang 版本:1.19
Badger 初始化
// 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
}
错误来自 badger 内部库,请按照错误中的路径进行操作。
即使我像这样初始化 badger db
// 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
}
我遇到了同样的错误。
答: 暂无答案
评论