Error during preflight check for storagenode databases: preflight: database "bandwidth"

Today I realized that my node is down. I don’t know how long it was offline, but I didn’t receive any letters. Hope I haven’t been disqualified

sudo docker logs storagenode
2020-10-27T18:31:42.376Z        INFO    Configuration loaded    {"Location": "/app/config/config.yaml"}
2020-10-27T18:31:42.407Z        INFO    Operator email  {"Address": ""}
2020-10-27T18:31:42.407Z        INFO    Operator wallet {"Address": ""}
2020-10-27T18:31:45.656Z        INFO    Telemetry enabled
2020-10-27T18:31:45.679Z        INFO    db.migration    Database Version        {"version": 45}
Error: Error during preflight check for storagenode databases: preflight: database "bandwidth": expected schema does not match actual:   &dbschema.Schema{
        Tables: []*dbschema.Table{
                &{Name: "bandwidth_usage", Columns: {&{Name: "action", Type: "INTEGER"}, &{Name: "amount", Type: "BIGINT"}, &{Name: "created_at", Type: "TIMESTAMP"}, &{Name: "satellite_id", Type: "BLOB"}}},
-               (
-                       s"""
-                       Name: bandwidth_usage_rollups
-                       Columns:
-                               Name: action
-                               Type: INTEGER
-                               Nullable: false
-                               Default: ""
-                               Reference: nil
-                               Name: amount
-                               Type: BIGINT
-                               Nullable: false
-                               Default: ""
-                               Reference: nil
-                               Name: interval_start
-                               Type: TIMESTAMP
-                               Nullable: false
-                               Default: ""
-                               Reference: nil
-                               Name: satellite_id
-                               Type: BLOB
-                               Nullable: false
-                               Default: ""
-                               Reference: nil
-                       PrimaryKey: action interval_start satellite_id
-                       Uniques:
- 
-                       s"""
-               ),
        },
-       Indexes: []*dbschema.Index{
-               s`Index<Table: bandwidth_usage, Name: idx_bandwidth_usage_created, Columns: created_at, Unique: false, Partial: "">`,
-               s`Index<Table: bandwidth_usage, Name: idx_bandwidth_usage_satellite, Columns: satellite_id, Unique: false, Partial: "">`,
-       },
+       Indexes: nil,
  }

        storj.io/storj/storagenode/storagenodedb.(*DB).Preflight:424
        main.cmdRun:199
        storj.io/private/process.cleanup.func1.4:362
        storj.io/private/process.cleanup.func1:380
        github.com/spf13/cobra.(*Command).execute:842
        github.com/spf13/cobra.(*Command).ExecuteC:950
        github.com/spf13/cobra.(*Command).Execute:887
        storj.io/private/process.ExecWithCustomConfig:88
        storj.io/private/process.ExecCustomDebug:70
        main.main:335
        runtime.main:204

I tried to fix this error with this guide but without success. Every step was done without problems, but after I tried to start node I got the same error

1 Like

Hello @mckk,
Welcome to the forum!

  1. Stop the storagenode
  2. Remove the bandwidth.db
  3. Execute either with a local installed sqlite3 (make sure the version is not older than v3.25.2) or with a docker version (you can use https://support.storj.io/hc/en-us/articles/360029309111 as a reference), specify the correct path to the bandwidth.db:
sqlite3 bandwidth.db
  1. When you see a sqlite> prompt, execute this script:
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. Start the storagenode
  2. Check your logs
1 Like

Thanks! That helped!

1 Like