Fixed an error in a peculiar way. Could anybody explain to me why this has worked?

Hi, a newbie here, nice to meet you all. I’m loving this software so far.

I’ve got a weird question.
This evening I tried to boot anytype and it launched an error stating something along the lines of “Anytype Helper has crashed, a log has been created.”, I should have taken a screenshot.

At first I though it was because of the 0.37.3 update, but then I remebered:
The cause of this was Anytype forcibly being shut down due to a power cut or blackout.

Below this text you’ll find the log in question.

Summary

panic: runtime error: index out of range [3] with length 0 [recovered]
panic:
== Recovering from initIndex crash ==
File Info: [ID: 3, Size: 48877, Zeros: 48877]
isEnrypted: false checksumLen: 0 checksum: indexLen: 0 index:
== Recovered ==

goroutine 49 [running]:
github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest.func1.1()
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/table/table.go:353 +0xa8
github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest.func1()
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/table/table.go:399 +0xc2

panic({0x7ff6cbc901a0, 0xc000ae2060})
/Users/runner/hostedtoolcache/go/1.20.12/x64/src/runtime/panic.go:884 +0x213
github.com/google/flatbuffers/go.GetInt32(...)
/Users/runner/go/pkg/mod/github.com/google/[email protected]/go/encode.go:85
github.com/google/flatbuffers/go.GetUOffsetT(...)
/Users/runner/go/pkg/mod/github.com/google/[email protected]/go/encode.go:121
github.com/dgraph-io/badger/v4/fb.GetRootAsTableIndex(...)
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/fb/TableIndex.go:14
github.com/dgraph-io/badger/v4/table.(*Table).readTableIndex(0xc00010a0c0)
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/table/table.go:707 +0x15e
github.com/dgraph-io/badger/v4/table.(*Table).initIndex(0xc00010a0c0)
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/table/table.go:464 +0x19d
github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest(0xc00010a0c0)
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/table/table.go:403 +0x7f
github.com/dgraph-io/badger/v4/table.OpenTable(0xc000ad2220, {0x0, 0x1, 0x200000, 0x0, 0x0, 0x3f847ae147ae147b, 0x1000, 0x0, 0x0, …})
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/table/table.go:309 +0x278
github.com/dgraph-io/badger/v4.newLevelsController.func1({0xc000ae62a0, 0x72}, {0x72?, 0x7267075203280120?, 0x4970756f?})
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/levels.go:150 +0x1f9
created by github.com/dgraph-io/badger/v4.newLevelsController
/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/levels.go:129 +0x585

I tried using Badger to no avail, I noticed that it “couldn’t” read a file named “000003.sst”, stating that there was no route to such file despite it being there. Out of curiosity I opened it with Notepad++ and noticed that only “null” values filled the file, contrary to its peers “000001.sst” and “000002.sst”

After resignating myself to start over, I decided to cut&paste the “data” folder inside /Roaming/Anytype to my Desktop.

After that, the app booted without problems and I noticed that the “data” folder was created once again. Inside of it, I found a folder with the exact same AnytypeID as the previously-moved-to-desktop folder.

In a sudden attack of tomfoolery, I decided to copy my old “000001.sst” & “000002.sst” files into my new “data/AnytypeID/spacetore” folder, leaving out the “empty” and corrupted “000003.sst”

Despite thinking it wouldn’t work because that’s not how databases work, it worked! I recovered all of the work that took me hours to look like I wanted!

Would anybody mind explaining why this worked? I’m very curious to know why.

I’d be more than happy to share any other information needed.
My machine is running Windows 10 Home 64x 22H2

Lastly, I posted this in the “Discussion” section because it seemed more like a “discussion” rather than a bug report or a request for help. I hope I didn’t make a mistake, I apologize in advanced if actually did.

Have a lovely one, everybody, and happy new year. :slight_smile:

4 Likes

Welcome @MidHeavy !

Thank you so much for this excellent clear and detailed report! :+1:
I hope this will help the developers to find a solution for this recurring problem!

2 Likes

Welcome to the community @MidHeavy !

This is a very well explained solution to a problem that has affected almost everyone using Anytype on Windows.

About this, your work isn’t lost as long as you were connected to the internet until that issue occured, reinstalling the app then logging in will get you all of your data back.

3 Likes

Link to the relevant BR and the fix.

3 Likes

Thank you! Personally, when a problem is presented to me, I always appreciate having as much information as possible!

Hello! I apologize for the late reply. In my experience, after clearing the “data” folder and rebooting anytype, all of my work seemed to be lost as it wasn’t restored until I copy&pasted my older “.sst” files.

Could it be I didn’t correctly backup my data in the cloud beforehand!

Thank you for the kind reply :slight_smile:

1 Like

Hi! The fix didn’t quite work for me. I though that this may be a workaround, maybe?

Sadly, I do not know how to reproduce the original issue. It could maybe have proven useful to know if I “fixed” it or if it was sheer luck.

Thank you!