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]
== Recovering from initIndex crash ==
File Info: [ID: 3084670, Size: 23044511, Zeros: 417]
isEnrypted: false checksumLen: 0 checksum:  indexLen: 0 index: [] 
== Recovered ==

goroutine 8857 [running]:*Table).initBiggestAndSmallest.func1.1()
	C:/Temp/Go/pkg/mod/[email protected]/table/table.go:351 +0xa8*Table).initBiggestAndSmallest.func1()
	C:/Temp/Go/pkg/mod/[email protected]/table/table.go:397 +0xc2
panic({0x1bdcaa0, 0xc0164223f0})
	C:/Program Files/Go/src/runtime/panic.go:1038 +0x215
	C:/Temp/Go/pkg/mod/[email protected]+incompatible/go/encode.go:47
	C:/Temp/Go/pkg/mod/[email protected]+incompatible/go/encode.go:121
	C:/Temp/Go/pkg/mod/[email protected]/fb/TableIndex.go:14*Table).readTableIndex(0xc0164303c0)
	C:/Temp/Go/pkg/mod/[email protected]/table/table.go:707 +0x15e*Table).initIndex(0xc0164303c0)
	C:/Temp/Go/pkg/mod/[email protected]/table/table.go:462 +0x196*Table).initBiggestAndSmallest(0xc0164303c0)
	C:/Temp/Go/pkg/mod/[email protected]/table/table.go:401 +0x7f, {0x0, 0x1, 0x200000, 0x0, 0x0, 0x3f847ae147ae147b, 0x1000, 0x0, 0x1, ...})
	C:/Temp/Go/pkg/mod/[email protected]/table/table.go:308 +0x272{0xc0163422c0, 0x20}, {0x0, 0xc00845f680, 0x0})
	C:/Temp/Go/pkg/mod/[email protected]/levels.go:150 +0x1f9
created by
	C:/Temp/Go/pkg/mod/[email protected]/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.