[badger v3] panic: runtime error: slice bounds out of range

I’m working on creating a fork of GitHub - ethersphere/bee: Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; censorship-resistant and self-sustaining network for storing your (application) data. that uses BadgerDB instead of LevelDB to store 4KB chunks and the metadata for them. The database is currently set to store up to 5,000,000 chunks and their metadata at one time.

I ran into the error below and I don’t know how to troubleshoot it.

The db interface code is mostly in: bee/db.go at master · mrsimicsak/bee · GitHub

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

go version go1.15.12 windows/amd64

What operating system are you using?

Ubuntu 20.04 ARM64 on Raspberry Pi 4 with 4GB ram (cross compiled on Windows 10 Pro x64)

What version of Badger are you using?

from go.mod:

github.com/dgraph-io/badger/v3 v3.2011.1

Does this issue reproduce with the latest master?

How do I use the master version?

Steps to Reproduce the issue

  1. Download repo mrsimicsak/bee repo from github
  2. build using powershell with make installed:
$env:GOOS="linux"
$env:GOARCH="arm64"
make binary
  1. Start the node.
  2. Fund the node.
  3. Wait for the node to crash.

What Badger options were set?

o := badger.DefaultOptions(path)
o.SyncWrites = DefaultSyncWrites
o.ValueThreshold = DefaultValueThreshold
o.ValueLogMaxEntries = DefaultValueLogMaxEntries
o.Logger = nil // Dont enable the badger logs

CGO_ENABLED=0 was used when installing via go get.

What did you do?

See Steps to Reproduce the issue.

What did you expect to see?

Nothing.

What did you see instead?

 panic: runtime error: slice bounds out of range [1073830837:0]
May 12 19:10:25 ubuntu bee[13507]: goroutine 29736751 [running]:
May 12 19:10:25 ubuntu bee[13507]: github.com/dgraph-io/badger/v3.(*valueLog).write.func2(0x4005f7e690, 0x4005f7e690, 0x400558ebe0)
May 12 19:10:25 ubuntu bee[13507]:         github.com/dgraph-io/badger/v3@v3.2011.1/value.go:818 +0x1bc
May 12 19:10:25 ubuntu bee[13507]: github.com/dgraph-io/badger/v3.(*valueLog).write(0x40011e89d0, 0x40073db400, 0x1, 0xa, 0x0, 0x0)
May 12 19:10:25 ubuntu bee[13507]:         github.com/dgraph-io/badger/v3@v3.2011.1/value.go:874 +0x388
May 12 19:10:25 ubuntu bee[13507]: github.com/dgraph-io/badger/v3.(*DB).writeRequests(0x40011e8800, 0x40073db400, 0x1, 0xa, 0x40, 0x40)
May 12 19:10:25 ubuntu bee[13507]:         github.com/dgraph-io/badger/v3@v3.2011.1/db.go:759 +0x74
May 12 19:10:25 ubuntu bee[13507]: github.com/dgraph-io/badger/v3.(*DB).doWrites.func1(0x40073db400, 0x1, 0xa)
May 12 19:10:25 ubuntu bee[13507]:         github.com/dgraph-io/badger/v3@v3.2011.1/db.go:830 +0x4c
May 12 19:10:25 ubuntu bee[13507]: created by github.com/dgraph-io/badger/v3.(*DB).doWrites
May 12 19:10:25 ubuntu bee[13507]:         github.com/dgraph-io/badger/v3@v3.2011.1/db.go:883 +0x264

additional panic messages:

-- Logs begin at Sun 2021-05-09 13:09:53 UTC, end at Fri 2021-05-14 02:08:46 UTC. --
May 10 00:49:27 ubuntu bee[32813]: panic: runtime error: slice bounds out of range [1073856877:0]
May 10 01:46:28 ubuntu bee[32992]: panic: runtime error: slice bounds out of range [1073796972:0]
May 10 22:21:21 ubuntu bee[33239]: panic: runtime error: slice bounds out of range [1073820119:0]
-- Reboot --
May 11 12:28:24 ubuntu bee[2255]: panic: runtime error: slice bounds out of range [1073748314:0]
May 11 14:39:49 ubuntu bee[2710]: panic: runtime error: slice bounds out of range [1073764676:0]
May 11 16:57:13 ubuntu bee[3691]: panic: runtime error: slice bounds out of range [1073784113:0]
May 11 18:56:28 ubuntu bee[4519]: panic: runtime error: slice bounds out of range [1073823242:0]
May 11 19:38:24 ubuntu bee[5741]: panic: runtime error: slice bounds out of range [1073760006:0]
May 12 14:42:20 ubuntu bee[12762]: panic: runtime error: slice bounds out of range [1073847359:0]
May 12 15:42:06 ubuntu bee[13032]: panic: runtime error: slice bounds out of range [1073798834:0]
May 12 16:42:53 ubuntu bee[13254]: panic: runtime error: slice bounds out of range [1073867055:0]
May 12 19:10:25 ubuntu bee[13507]: panic: runtime error: slice bounds out of range [1073830837:0]
May 13 06:07:18 ubuntu bee[15009]: panic: runtime error: slice bounds out of range [1073815748:0]
May 13 07:14:28 ubuntu bee[19338]: panic: runtime error: slice bounds out of range [1073778444:0]
May 13 11:27:04 ubuntu bee[19813]: panic: runtime error: slice bounds out of range [1073835425:0]
May 13 12:27:19 ubuntu bee[21070]: panic: runtime error: slice bounds out of range [1073879442:0]
May 13 13:29:59 ubuntu bee[22348]: panic: runtime error: slice bounds out of range [1073770476:0]
May 13 14:28:36 ubuntu bee[22578]: panic: runtime error: slice bounds out of range [1073857544:0]
May 13 15:33:59 ubuntu bee[22751]: panic: runtime error: slice bounds out of range [1073904679:0]
May 13 17:30:18 ubuntu bee[23766]: panic: runtime error: slice bounds out of range [1073898678:0]
May 13 18:38:26 ubuntu bee[24026]: panic: runtime error: slice bounds out of range [1073744229:0]
May 13 19:36:09 ubuntu bee[24189]: panic: runtime error: slice bounds out of range [1073843775:0]
May 13 21:01:56 ubuntu bee[24423]: panic: runtime error: slice bounds out of range [1073906181:0]