V1.0.18 panic: Is it possible to restore data if zw directory is corrupt

– EDIT –

It seems clear the problem is in the zw data. If I move it out, zero can start no problem, as can alpha, but it causes problems when querying.

this is covered here:

Is there a way for zero to rebuild zw data?


An old database that is still on version 1 has stopped working, with zero presenting the runtime error of slice bounds out of range.

V1.0.18 panic: runtime error: slice bounds out of range [:8] with capacity 5

I want to upgrade to the latest version, but need to be able to recover this data if possible. Unfortunately they haven’t been backing it up.

I understand this is our own fault, but if we could recover it that would help a lot.

What I want to do

Fix the data so zero can open it again

What I did

I’ve tried giving the database more disk space or opening with later versions of dgraph, all to no avail

Dgraph metadata

I0423 13:36:50.706545       1 run.go:98] Setting up grpc listener at:
zero-master-1  | I0423 13:36:50.706751       1 run.go:98] Setting up http listener at:
zero-master-1  | badger 2024/04/23 13:36:51 INFO: All 4 tables opened in 527ms
zero-master-1  | badger 2024/04/23 13:36:51 INFO: Replaying file id: 190 at offset: 23292149
zero-master-1  | badger 2024/04/23 13:36:51 INFO: Replay took: 14.937µs
zero-master-1  | panic: runtime error: slice bounds out of range [:8] with capacity 5
zero-master-1  | 
zero-master-1  | goroutine 1 [running]:
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger.(*valuePointer).Decode(0xc00020cf7c, 0xc0157db443, 0x2, 0x5)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger/structs.go:45 +0x63
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger.(*valueLog).populateDiscardStats(0xc0006cc888, 0x8000000, 0x0)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger/value.go:1437 +0x205
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger.(*valueLog).open(0xc0006cc888, 0xc0006cc700, 0x31000000be, 0xc0016368c4, 0xc0000c1a40, 0x0, 0xc0000d2333)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger/value.go:855 +0xea2
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger.Open(0x158d186, 0x2, 0x158d186, 0x2, 0x0, 0x2, 0x2, 0x1, 0x100, 0x173ace0, ...)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/badger/db.go:317 +0xe0a
zero-master-1  | github.com/dgraph-io/dgraph/dgraph/cmd/zero.run()
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/zero/run.go:223 +0x71c
zero-master-1  | github.com/dgraph-io/dgraph/dgraph/cmd/zero.init.0.func1(0xc00016f680, 0xc0006e20c0, 0x0, 0x1)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/zero/run.go:73 +0x66
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/spf13/cobra.(*Command).execute(0xc00016f680, 0xc0006e20a0, 0x1, 0x1, 0xc00016f680, 0xc0006e20a0)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/spf13/cobra/command.go:702 +0x285
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1e5ffe0, 0xc0000c01c0, 0x2, 0x2)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/spf13/cobra/command.go:783 +0x2c9
zero-master-1  | github.com/dgraph-io/dgraph/vendor/github.com/spf13/cobra.(*Command).Execute(...)
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/spf13/cobra/command.go:736
zero-master-1  | github.com/dgraph-io/dgraph/dgraph/cmd.Execute()
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:60 +0x8d
zero-master-1  | main.main()
zero-master-1  | 	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/main.go:33 +0x94