Storage node preflight database error: file is not a database

I had preflight errors before and I managed to repair them successfully すbut now there is no info about which db file is corrupted
@Alexey please help

2020-04-02T19:59:51.684Z INFO db.migration Database Version {"version": 33}
Error: Error during preflight check for storagenode databases: storage node preflight database error: file is not a database
storj.io/storj/private/dbutil/sqliteutil.QuerySchema.func1:35
storj.io/storj/private/dbutil/sqliteutil.QuerySchema:53
storj.io/storj/storagenode/storagenodedb.(*DB).Preflight:293
main.cmdRun:198
storj.io/storj/pkg/process.cleanup.func1.2:312
storj.io/storj/pkg/process.cleanup.func1:330
github.com/spf13/cobra.(*Command).execute:826
github.com/spf13/cobra.(*Command).ExecuteC:914
github.com/spf13/cobra.(*Command).Execute:864
storj.io/storj/pkg/process.ExecWithCustomConfig:84
storj.io/storj/pkg/process.ExecCustomDebug:66
main.main:328
runtime.main:203
2020-04-02T19:59:56.976Z INFO Configuration loaded from: /app/config/config.yaml

First of all - you should figure out, which one is died.
Please, use this manual to check all your databases: https://support.storj.io/hc/en-us/articles/360029309111-How-to-fix-a-database-disk-image-is-malformed-

#sqlite3 notifications.db "PRAGMA integrity_check;"
ok
#sqlite3 pieceinfo.db "PRAGMA integrity_check;"
ok
#sqlite3 satellites.db "PRAGMA integrity_check;"
ok
#sqlite3 heldamount.db "PRAGMA integrity_check;"
ok
#sqlite3 orders.db "PRAGMA integrity_check;"
Error: database is locked
#sqlite3 piece_spaced_used.db "PRAGMA integrity_check;"
ok
#sqlite3 storage_usage.db "PRAGMA integrity_check;"
ok
#sqlite3 used_seria.db "PRAGMA integrity_check;"
ok
#sqlite3 info.db "PRAGMA integrity_check;"
ok
#sqlite3 piece_expiration.db "PRAGMA integrity_check;"
ok
#sqlite3 reputation.db "PRAGMA integrity_check;"
ok

OK, I can unlock by replacing the file

#cp orders.db orders.db.bak
#rm orders.db
#mv orders.db.bak orders.db

but getting still the same error:
Error: Error during preflight check for storagenode databases: storage node preflight database error: file is not a database

despite now orders.db is: ok

Have you stopped the storagenode before the check?

Make sure that you checked the actual dbs not the copies.

You missed the one database - bandwidth.db

Yes

As in output, all files are in their original form

I checked, just missed to paste here, it is ok

maybe remount drive (internal disk)

No, not needed.
But you can enable the debug log level in the config.yaml and restart the storagenode

DEBUG Unrecoverable error {“error”: “Error during preflight check for storagenode databases: storage node preflight database error: file is not a database\n\tstorj.io/storj/private/dbutil/sqliteutil.QuerySchema.func1:35\n\tstorj.io/storj/private/dbutil/sqliteutil.QuerySchema:53\n\tstorj.io/storj/storagenode/storagenodedb.(*DB).Preflight:293\n\tmain.cmdRun:198\n\tstorj.io/storj/pkg/process.cleanup.func1.2:312\n\tstorj.io/storj/pkg/process.cleanup.func1:330\n\tgithub.com/spf13/cobra.(*Command).execute:826\n\tgithub.com/spf13/cobra.(*Command).ExecuteC:914\n\tgithub.com/spf13/cobra.(*Command).Execute:864\n\tstorj.io/storj/pkg/process.ExecWithCustomConfig:84\n\tstorj.io/storj/pkg/process.ExecCustomDebug:66\n\tmain.main:328\n\truntime.main:203”, “errorVerbose”: “Error during preflight check for storagenode databases: storage node preflight database error: file is not a database\n\tstorj.io/storj/private/dbutil/sqliteutil.QuerySchema.func1:35\n\tstorj.io/storj/private/dbutil/sqliteutil.QuerySchema:53\n\tstorj.io/storj/storagenode/storagenodedb.(*DB).Preflight:293\n\tmain.cmdRun:198\n\tstorj.io/storj/pkg/process.cleanup.func1.2:312\n\tstorj.io/storj/pkg/process.cleanup.func1:330\n\tgithub.com/spf13/cobra.(*Command).execute:826\n\tgithub.com/spf13/cobra.(*Command).ExecuteC:914\n\tgithub.com/spf13/cobra.(*Command).Execute:864\n\tstorj.io/storj/pkg/process.ExecWithCustomConfig:84\n\tstorj.io/storj/pkg/process.ExecCustomDebug:66\n\tmain.main:328\n\truntime.main:203\n\tmain.cmdRun:200\n\tstorj.io/storj/pkg/process.cleanup.func1.2:312\n\tstorj.io/storj/pkg/process.cleanup.func1:330\n\tgithub.com/spf13/cobra.(*Command).execute:826\n\tgithub.com/spf13/cobra.(*Command).ExecuteC:914\n\tgithub.com/spf13/cobra.(*Command).Execute:864\n\tstorj.io/storj/pkg/process.ExecWithCustomConfig:84\n\tstorj.io/storj/pkg/process.ExecCustomDebug:66\n\tmain.main:328\n\truntime.main:203”}

I don’t see such file as : “storagenodedb.”

doesn’t exist

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         4/2/2020  11:31 PM        6316032 bandwidth.db
-a----        3/31/2020   6:31 PM          32768 heldamount.db
-a----        3/31/2020   6:31 PM          16384 info.db
-a----        3/31/2020   6:31 PM          24576 notifications.db
-a----         4/2/2020  11:02 PM       84365312 orders.db
-a----        3/31/2020   6:31 PM      114331648 pieceinfo.db
-a----        3/31/2020   6:31 PM          53248 piece_expiration.db
-a----        3/31/2020   6:31 PM          24576 piece_spaced_used.db
-a----        3/31/2020   6:31 PM          20480 reputation.db
-a----        2/19/2020   5:03 PM          32768 revocations.db
-a----        3/31/2020   6:31 PM          32768 satellites.db
-a----        3/31/2020   6:31 PM         196608 storage_usage.db
-a----         4/2/2020  11:40 PM      265232384 used_serial.db

It does, and it is ok.

Sorry, another missed

got it! I didn’t check: used_serial.db and it gives me “Error: file is encrypted or is not a database”

Can I just remove?

Yes, you can try, but node will not start.
Please, do this:

  1. Stop the storagenode
  2. Remove the used_serial.db and used_seria.db (seems you typed it manually, not by [Tab]).
  3. Execute
sqlite3 used_serial.db
CREATE TABLE used_serial_ (
                                                satellite_id  BLOB NOT NULL,
                                                serial_number BLOB NOT NULL,
                                                expiration    TIMESTAMP NOT NULL
                                        );
CREATE UNIQUE INDEX pk_used_serial_ ON used_serial_(satellite_id, serial_number);
CREATE INDEX idx_used_serial_ ON used_serial_(expiration);
.exit
  1. Try to start the storagenode

Also, please, update your docker run command: https://documentation.storj.io/setup/cli/storage-node#running-the-storage-node

2 Likes

It worked! Thanks @Alexey ! Data is flowing.

3 Likes

Hi bumping this…
getting this:
DEBUG Unrecoverable error {“error”: "Error during preflight check for storagenode databases: storage node preflight database error: bandwidth: schema check failed: disk I/O error: input/output error\n\tstorj.io/storj/storagenode/storagenodedb.(*DB).Preflight:304\n\tmain.cmdRun:190\n\tstorj.io/private/process.cleanup.func1.4:359\n\tstorj.io/private

this did not work and i am getting a dize 0 bandwidth.db:

anything else i can try?

The disk I/O error would seem to suggest a problem with the disk/file system. Have you tried running a disk/filesystem check?

i am running as a docker…disk seems ok

It may seem okay, but 1 bad block could kill a db file. Did you run a disk check? fsck in Linux or Disk Check in Windows? It would help if you gave us more info on your setup. Windows/Linux? How drive is attached? How old is your node? Did it recently get updated?

Did you already try the steps outlined here?

I tried this: https://support.storj.io/hc/en-us/articles/360029309111-How-to-fix-a-database-disk-image-is-malformed-

and ended up with a 0kb file…

It’s an unraid docker, i think it got corrupt during a power trip at my house.

Then

  1. Stop the storagenode
  2. Check disk
  3. Remove the bandwidth.db if it’s still zero
  4. Execute (replace the /path/to/the/data/storage with your actual path to the databases):
docker run -it --rm --mount type=bind,source=/path/to/the/data/storage,destination=/data sstc/sqlite3 sqlite3 bandwidth.db
CREATE TABLE bandwidth_usage (
                                                satellite_id  BLOB    NOT NULL,
                                                action        INTEGER NOT NULL,
                                                amount        BIGINT  NOT NULL,
                                                created_at    TIMESTAMP NOT NULL
                                        );
CREATE INDEX idx_bandwidth_usage_satellite ON bandwidth_usage(satellite_id);
CREATE INDEX idx_bandwidth_usage_created   ON bandwidth_usage(created_at);
CREATE TABLE bandwidth_usage_rollups (
                                                                                interval_start  TIMESTAMP NOT NULL,
                                                                                satellite_id    BLOB    NOT NULL,
                                                                                action          INTEGER NOT NULL,
                                                                                amount          BIGINT  NOT NULL,
                                                                                PRIMARY KEY ( interval_start, satellite_id, action )
                                                                        );
.exit
  1. Try to start the node