A tool to fix the 'Anytype Helper Crashed' Issue

Some Windows users are encountering frequent crashes with the Anytype app, preventing them from accessing their accounts. This issue commonly occurs after unexpected power loss or improper shutdown, leading to database corruption.

The bug will be automatically fixed in the upcoming Anytype update. However, for those who want to address it in the meantime, you can use this tool.


Instructions to fix the corrupted db:

For Windows Users
Step 1: Downloading Badger

Step 2: Accessing PowerShell

  • Open PowerShell: Press Windows Key + X and select “Windows PowerShell” from the menu. Alternatively, you can search for “PowerShell” in the Start menu.

Step 3: Running Badger

  • Navigate to the Download Folder and open the badger. This will open PowerShell.
  • In the PowerShell window, use the cd command to change the directory to where you downloaded badger.exe. For example, if it’s in your Downloads folder, you would type cd Downloads.
  • Run Badger: Execute the following command:

.\badger.exe --dir <spacestore_db_path> fix

  • :point_down: Replace “spacestore_db_path” with the actual path to your “Spacestore database”

Finding the AppData for the “anytype” App:

The “anytype” app (being an Electron app), stores its data in the AppData folder on your Windows system. To find this:

  • Open File Explorer: Press Windows Key + E to open the File Explorer.

  • Access AppData: Type %AppData% in the address bar of the File Explorer and press Enter. This will take you to the C:\Users[YourUsername]\AppData\Roaming folder.

  • Locate Anytype Folder: In the Roaming folder, look for a folder named “Anytype”. Inside it you should find “data/” folder. (If you use beta channel it will be “beta/data/”)

  • Within this folder you will find “spacestore” folder. You need to copy (ctrl+c) it’s path and put it to the command line mentioned above, replacing “spacestore_db_path”.

    The command line it should be something like this:
    .\badger.exe --dir C:\Users\Username1\AppData\Roaming\anytype\data\accountId\spacestore


This tool creates the backup of the corrupted db before trying to fix it. Backup will be stored at “spacestore_corrupted_backup_”

2 Likes

When/Who Should Use This Tool:

  1. After Windows BSOD or Power Loss:
  • Use this tool when encountering a Blue Screen of Death (BSOD), loss of access after power outage or improper shutdown on a Windows system.
  • Specifically, if the application is not opening and displays an error.
  1. Users in Local-Only Mode with DB Error:
  • Users operating in a local-only mode and encounter a panic error
  1. Users Recovering from Nodes with Data Loss:
  • If users have attempted to recover from nodes, especially with an empty data folder or on another device, and still notice a loss of data (e.g., missing objects or changes)

:stop_sign: Precaution: Before Using the Tool: Remove the “data” Folder
The root of the problem may be located in this folder and can be found in the following paths:

File > Show work directory or (C:\Users\Username1\AppData\Roaming\Anytype)

  • Anytype/data/<accountID> for standard release version
  • Anytype/beta/data/<accountID> folder for Pre-release version
  • Anytype/alpha/data/<accountID> folder for Alpha (internal) version
1 Like

This was waaaaay too complex for me, so I just uninstalled and reinstalled Anytype :slight_smile:

1 Like

It will hopefully cease to be an issue as of v0.38.0+ :crossed_fingers:

I am getting this error
Listening for /debug HTTP requests at port: 8080
jemalloc enabled: false
Using Go memory
badger 2024/02/08 21:35:24 ERROR: Received err: Opening table: “C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\000002.sst” error: failed to initialize table error: failed to read index. error: index length is 0 and checksum is empty: C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\000002.sst. Cleaning up…
Database is corrupted. Trying to fix it
Creating backup from C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore to C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore_corrupted_backup_1707408324
Error: unable to open database after fix attempt while opening memtables error: while opening fid: 6 error: while updating skiplist error: while truncate file: C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\00006.mem, error: truncate C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\00006.mem: The requested operation cannot be performed on a file with a user-mapped section open.

Usage:
badger fix [flags]

Flags:
-f, --backup-dir string Folder to backup to(default is _corrupted_backup)
-n, --force-not-empty Force delete not empty corrupted tables
-h, --help help for fix

Global Flags:
–dir string Directory where the LSM tree files are located. (required)
–vlog-dir string Directory where the value log files are located, if different from --dir

unable to open database after fix attempt while opening memtables error: while opening fid: 6 error: while updating skiplist error: while truncate file: C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\00006.mem, error: truncate C:\Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\00006.mem: The requested operation cannot be performed on a file with a user-mapped section open.

edit: I replaced my actual account Id with “accountID” here

@srushti335 can you please confirm that you’ve uninstalled the previous version, and installed v0.38.0? After doing so, you can also set your Version channel to “Pre-Release”.

@Angelo
I had the same error as @srushti335

I followed the steps in the OP, and received the same error. The error occurs after running step 3.

Steps I follow:

  1. Run badger fix with the command line as given above
  2. Error, ‘Table is not empty. Use --force-not-empty to delete it’
  3. Run badger fix again
  4. Error:

unable to open database after fix attempt while opening memtables error: while opening fid: 6 error: while updating skiplist error: while truncate file: C:\temp\spacestore\00006.mem, error: truncate C:\temp\spacestore\00006.mem: The requested operation cannot be performed on a file with a user-mapped section open.

I see something about this on the dgraph github from 5 years ago, but have no idea where to go from there.

hi @krsmith88, what version of Anytype are you using? Please see my comment above yours

@Angelo v0.38.0, but this is during the database restore process.

When I try to run v0.38.0 (pre-release) on the corrupted data folder I get these errors:
image

Hello! Could you please check that you have no running anytype processes? Probably some process locked badger files. Also you can try to find a process that opened \Users\srushti\AppData\Roaming\anytype\data\accountID\spacestore\00006.mem using Process Explorer - Sysinternals | Microsoft Learn

1 Like

There are definitely no Anytype processes running, and in Process Explorer, there are no processes locking the .mem files. The mem files are created by the fix command anyway, so if anything is locking them. It must be the badger process.

This is the full output from PowerShell for the badger fix command.


PS C:\temp\anytype> .\badger.exe --dir c:\temp\anytype\spacestore fix
Listening for /debug HTTP requests at port: 8080
jemalloc enabled: false
Using Go memory
badger 2024/02/15 09:15:50 ERROR: Received err: Opening table: "c:\\temp\\anytype\\spacestore\\000113.sst" error: failed to initialize table error: failed to read index. error: index length is 0 and checksum is empty: c:\temp\anytype\spacestore\000113.sst. Cleaning up...
Table is not empty. Use --force-not-empty to delete it
Num Allocated Bytes at program end: 0 B
PS C:\temp\anytype> .\badger.exe --dir c:\temp\anytype\spacestore fix --force-not-empty
Listening for /debug HTTP requests at port: 8080
jemalloc enabled: false
Using Go memory
badger 2024/02/15 09:16:03 ERROR: Received err: Opening table: "c:\\temp\\anytype\\spacestore\\000113.sst" error: failed to initialize table error: failed to read index. error: index length is 0 and checksum is empty: c:\temp\anytype\spacestore\000113.sst. Cleaning up...
Database is corrupted. Trying to fix it
Creating backup from c:\temp\anytype\spacestore to c:\temp\anytype\spacestore_corrupted_backup_1707988563
Error: unable to open database after fix attempt while opening memtables error: while opening fid: 9 error: while updating skiplist error: while truncate file: c:\temp\anytype\spacestore\00009.mem, error: truncate c:\temp\anytype\spacestore\00009.mem: The requested operation cannot be performed on a file with a user-mapped section open.

Usage:
  badger fix [flags]

Flags:
  -f, --backup-dir string   Folder to backup to(default is <name>_corrupted_backup)
  -n, --force-not-empty     Force delete not empty corrupted tables
  -h, --help                help for fix

Global Flags:
      --dir string        Directory where the LSM tree files are located. (required)
      --vlog-dir string   Directory where the value log files are located, if different from --dir

unable to open database after fix attempt while opening memtables error: while opening fid: 9 error: while updating skiplist error: while truncate file: c:\temp\anytype\spacestore\00009.mem, error: truncate c:\temp\anytype\spacestore\00009.mem: The requested operation cannot be performed on a file with a user-mapped section open.

PS C:\temp\anytype> .\badger.exe --dir c:\temp\anytype\spacestore fix --force-not-empty
Listening for /debug HTTP requests at port: 8080
jemalloc enabled: false
Using Go memory
badger 2024/02/15 09:18:17 ERROR: Received err: Opening table: "c:\\temp\\anytype\\spacestore\\000113.sst" error: failed to initialize table error: failed to read index. error: index length is 0 and checksum is empty: c:\temp\anytype\spacestore\000113.sst. Cleaning up...
Database is corrupted. Trying to fix it
Creating backup from c:\temp\anytype\spacestore to c:\temp\anytype\spacestore_corrupted_backup_1707988697
Error: unable to open database after fix attempt while opening memtables error: while opening fid: 10 error: while updating skiplist error: while truncate file: c:\temp\anytype\spacestore\00010.mem, error: truncate c:\temp\anytype\spacestore\00010.mem: The requested operation cannot be performed on a file with a user-mapped section open.

Usage:
  badger fix [flags]

Flags:
  -f, --backup-dir string   Folder to backup to(default is <name>_corrupted_backup)
  -n, --force-not-empty     Force delete not empty corrupted tables
  -h, --help                help for fix

Global Flags:
      --dir string        Directory where the LSM tree files are located. (required)
      --vlog-dir string   Directory where the value log files are located, if different from --dir

unable to open database after fix attempt while opening memtables error: while opening fid: 10 error: while updating skiplist error: while truncate file: c:\temp\anytype\spacestore\00010.mem, error: truncate c:\temp\anytype\spacestore\00010.mem: The requested operation cannot be performed on a file with a user-mapped section open.

PS C:\temp\anytype>

1 Like

@Angelo @smalenkov
I know this probably isn’t a priority anymore, but is there a way that I can open the database and read the files? Even in a text editor would be amazing.

I want to try and recover any data between my last backup, and the date that the DB became corrupt. Unfortunately due to firewalls I have to operate in local mode.