Badger crashes re table index out of range

Using Badger (latest) v3.2103.2 on Windows, Go 1.17.6. Anytime it tries to open the database, the below panic happens (i.e. endless crashes now).

I am using it with about 2 billion records. It was running fine for 2 weeks. The server restarted a few times, so the application was terminated without signal.
This is quite frustrating as it’s happening on a production server, and there are 2 obvious distinct problems:

  1. Looks like a random terminate of the process just corrupts your database?!?
  2. Even if the database is corrupt, then it shouldn’t crash obviously. The open function should return an error something like “error opening database: table XYZ corrupt”.

Is there any way to fix this? Just recreating the 2 billion record database is obviously a pain, and without a proper fix recreating it would just cause the same problem to happen again in ~2 weeks.

2022/02/13 22:08:28 panic: runtime error: index out of range [3] with length 0 [recovered]
	panic: 
== Recovering from initIndex crash ==
File Info: [ID: 3084670, Size: 23044511, Zeros: 417]
isEnrypted: false checksumLen: 0 checksum:  indexLen: 0 index: [] 
== Recovered ==

goroutine 8857 [running]:
github.com/dgraph-io/badger/v3/table.(*Table).initBiggestAndSmallest.func1.1()
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/table/table.go:351 +0xa8
github.com/dgraph-io/badger/v3/table.(*Table).initBiggestAndSmallest.func1()
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/table/table.go:397 +0xc2
panic({0x1bdcaa0, 0xc0164223f0})
	C:/Program Files/Go/src/runtime/panic.go:1038 +0x215
github.com/google/flatbuffers/go.GetUint32(...)
	C:/Temp/Go/pkg/mod/github.com/google/flatbuffers@v2.0.5+incompatible/go/encode.go:47
github.com/google/flatbuffers/go.GetUOffsetT(...)
	C:/Temp/Go/pkg/mod/github.com/google/flatbuffers@v2.0.5+incompatible/go/encode.go:121
github.com/dgraph-io/badger/v3/fb.GetRootAsTableIndex(...)
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/fb/TableIndex.go:14
github.com/dgraph-io/badger/v3/table.(*Table).readTableIndex(0xc0164303c0)
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/table/table.go:707 +0x15e
github.com/dgraph-io/badger/v3/table.(*Table).initIndex(0xc0164303c0)
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/table/table.go:462 +0x196
github.com/dgraph-io/badger/v3/table.(*Table).initBiggestAndSmallest(0xc0164303c0)
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/table/table.go:401 +0x7f
github.com/dgraph-io/badger/v3/table.OpenTable(0xc016265ca0, {0x0, 0x1, 0x200000, 0x0, 0x0, 0x3f847ae147ae147b, 0x1000, 0x0, 0x1, ...})
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/table/table.go:308 +0x272
github.com/dgraph-io/badger/v3.newLevelsController.func1({0xc0163422c0, 0x20}, {0x0, 0xc00845f680, 0x0})
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/levels.go:150 +0x1f9
created by github.com/dgraph-io/badger/v3.newLevelsController
	C:/Temp/Go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/levels.go:129 +0x56d

Looks similar to an issue I am experiencing: Panic: Slice bounds out of range when indexing
Sadly,j it has not been resolved yet.