Failure to load after power loss

What’s The Bug?

My desktop machine suffered power loss due to weather. Anytype was open, but had not been used for at least 30m if not some hours.

It seems badger fails to recover from some part of this situation, but also it’s odd that either data had not been flushed from much earlier, or idle background execution produces dirty writes - both cases should probably be avoided.

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


goroutine 148 [running]:
github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest.func1.1()
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/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/v4@v4.2.0/table/table.go:399 +0xc2
panic({0x7ff7cf8d01a0, 0xc00004e150})
	/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/flatbuffers@v1.12.1/go/encode.go:85
github.com/google/flatbuffers/go.GetUOffsetT(...)
	/Users/runner/go/pkg/mod/github.com/google/flatbuffers@v1.12.1/go/encode.go:121
github.com/dgraph-io/badger/v4/fb.GetRootAsTableIndex(...)
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/fb/TableIndex.go:14
github.com/dgraph-io/badger/v4/table.(*Table).readTableIndex(0xc0008f4300)
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/table/table.go:707 +0x15e
github.com/dgraph-io/badger/v4/table.(*Table).initIndex(0xc0008f4300)
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/table/table.go:464 +0x19d
github.com/dgraph-io/badger/v4/table.(*Table).initBiggestAndSmallest(0xc0008f4300)
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/table/table.go:403 +0x7f
github.com/dgraph-io/badger/v4/table.OpenTable(0xc00097e6c0, {0x0, 0x1, 0x200000
, 0x0, 0x0, 0x3f847ae147ae147b, 0x1000, 0x0, 0x0, ...})
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/table/table.go:309 +0x278
github.com/dgraph-io/badger/v4.newLevelsController.func1({0xc0004c0380, 0x72}, {0x28?, 0xe688043a63696e6f?, 0x931a0103?})
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/levels.go:150 +0x1f9
created by github.com/dgraph-io/badger/v4.newLevelsController
	/Users/runner/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.2.0/levels.go:129 +0x585

How To Reproduce It

Leave anytype running in the background.

Power cycle the machine.

The Expected Behavior

I’d expect a few things to be different:

  • User data writes should get flushed relatively soon after user actions complete.
  • Idle operation should not maintain dirty pages or dirty buffers.
  • The reader should guard against this condition rather than panic’ing on it, as it it may otherwise be logically attackable.
  • On error, some kind of journal, log or other mechanism should be in place to recover cleanly, even if the last write happens to get lost.

Device

amd64 PC

OS

Windows 11

Anytype Version

Recent, hard to say as it doesn’t load

Technical Information

Can’t run

Crash Logs or Debug Files

crash_2024-02-04T21_42_36.log (2.15 KB)

I’ve had the same problem and now can’t open Anytype.

I have no access to my data and cannot load the app. I hope there is no corruption of the data.

Have you found any way to recover from this bug, and re-open Anytype?

My crash log attached.

crash_2024-02-05T23_11_46.log (2.2 KB)

What version do you use?

@raggi @simonsays

Would you both please download & install the latest version (v038.0) and try again?

Downloaded the version you linked, installed, received this message on load:

Screenshot 2024-02-07 100926

Hitting back put me to log in screen. Tried to log in with passphrase, and received this error:

Any further advice?

Closed, restarted, reopened, and anytype opens.
Let sync complete and rebuild indexes.

The file I had open when the desktop app crashed during power cycle is missing from desktop.

Turned phone offline, opened app, confirm its still there and no other files are missing by comparison of all objects.

Duplicated this file (out of concern desktop may force it to be deleted), and reconnected phone.

The duplicate version is now on desktop, but the original version is still missing.

Edit original version, and it re-appears on desktop.

Seems like problems all sorted. I’ll leave my notes above in case its helpful for someone.

1 Like

Just did. Now I don’t get that specific message anymore, but the app will crash after being used for a while.

1 Like