Error during preflight check for storagenode databases

6 posts were split to a new topic: ERROR piecestore:cache error getting current space used calculation: {“error”: “context canceled”}

I removed bandwidth.db as it was a copy of orders.db
I didn’t find bandwidth.db before doing cp command so I don’t make a backup.
I started docker and bandwidth.db was created but empty - no tables when I run .tables
And I receive this error:

    Error: Error during preflight check for storagenode databases: storage node preflight database error: bandwidth: expected schema does not match actual:   &dbschema.Schema{
     	Tables: []*dbschema.Table{
     		&{
     			Name: "bandwidth_usage",
    			Columns: []*dbschema.Column{
     				&{Name: "action", Type: "INTEGER"},
     				&{Name: "amount", Type: "BIGINT"},
     				&{Name: "created_at", Type: "TIMESTAMP"},
     				&{Name: "satellite_id", Type: "BLOB"},
     			},
    		},
    		&{
     			Name: "bandwidth_usage_rollups",
     			Columns: []*dbschema.Column{
     				&{Name: "action", Type: "INTEGER"},
     				&{Name: "amount", Type: "BIGINT"},
     				&{Name: "interval_start", Type: "TIMESTAMP"},
     				&{Name: "satellite_id", Type: "BLOB"},
     			},
     			PrimaryKey: []string{"action", "interval_start", "satellite_id"},
     		},
     	},
    + 	Tables: nil,
     	Indexes: []*dbschema.Index{
     		&{
    			Name:    "idx_bandwidth_usage_created",
     			Table:   "bandwidth_usage",
     			Columns: []string{"created_at"},
     		},
     		&{
     			Name:    "idx_bandwidth_usage_satellite",
     			Table:   "bandwidth_usage",
     			Columns: []string{"satellite_id"},
     		},
     	},
    + 	Indexes: nil,
      }

    	storj.io/storj/storagenode/storagenodedb.(*DB).Preflight:317
    	main.cmdRun:196
    	storj.io/storj/pkg/process.cleanup.func1.2:299
    	storj.io/storj/pkg/process.cleanup.func1:317
    	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:79
    	storj.io/storj/pkg/process.Exec:61
    	main.main:326
    	runtime.main:203
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 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 )
                                                                        );
CREATE INDEX idx_bandwidth_usage_satellite ON bandwidth_usage(satellite_id);
CREATE INDEX idx_bandwidth_usage_created   ON bandwidth_usage(created_at);
.exit
1 Like

It worked! Thank you!

1 Like

Hi, can you please help me? I have problems with bandwidth.db file during starting storagenode. At first it get me error about the file bandwidth.db is not a database, then I tried to resolve the issue using this:

This is not fix the issue, because there is no error inside the database. Then I tried to delete the file and start storagenode again, but i get this error:

Error: Error during preflight check for storagenode databases: preflight: database “bandwidth”: expected schema does not match actual: &dbschema.Schema{

  •   Tables: []*dbschema.Table{
    
  •           (
    
  •                   s"""
    
  •                   Name: bandwidth_usage
    
  •                   Columns:
    
  •                           Name: action
    
  •                           Type: INTEGER
    
  •                           Nullable: false
    
  •                           Default: ""
    
  •                           Reference: nil
    
  •                           Name: amount
    
  •                           Type: BIGINT
    
  •                           Nullable: false
    
  •                           Default: ""
    
  •                           Reference: nil
    
  •                           Name: created_at
    
  •                           Type: TIMESTAMP
    
  •                           Nullable: false
    
  •                   ... // 10 elided lines
    
  •                   s"""
    
  •           ),
    
  •           (
    
  •                   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
    
  •                   ... // 10 elided lines
    
  •                   s"""
    
  •           ),
    
  •   },
    
  •   Tables: nil,
    
  •   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:405
      storj.io/storj/storagenode/storagenodedb.(*DB).Preflight:352
      main.cmdRun:208
      storj.io/private/process.cleanup.func1.4:363
      storj.io/private/process.cleanup.func1:381
      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:385
      runtime.main:204

Hello @mravac ,
Welcome to the forum!

Please,

  1. Stop the storagenode
  2. Remove bandwidth.db
  3. Move all *.db to the different folder
  4. Start storagenode
    It should create all databases, but they will be empty.
  5. Stop the storagenode
  6. Move all backed up databases back with replace
  7. Start storagenode
  8. Check your logs