File is Not in Database Error for three databases: heldamount.db, piece-expiration.db and pricing.db

Probably after a bad power outage I got three corrupted files:
heldamount.db,
piece-expiration.db
and pricing.db.

Treatment with PRAGMA integrity_check failed - Error: file is not a database.
Is it possible to recreate these files and what commands are needed for this?

Thanks.

Hello @vivaldi,
Welcome to the forum!

  1. Stop the storagenode
  2. Remove heldamount.db, piece-expiration.db, piece_expiration.db and pricing.db
  3. Execute either with a local sqlite3 (v3.25.2 or later) or with a docker version (you can take it from https://support.storj.io/hc/en-us/articles/360029309111), replace the /path/to/ to the actual path:
sqlite3 /path/to/heldamount.db
  1. When you see a sqlite> prompt execute this script:
CREATE TABLE versions (version int, commited_at text);
CREATE TABLE paystubs (
                                                  period text NOT NULL,
                                                  satellite_id bytea NOT NULL,
                                                  created_at timestamp NOT NULL,
                                                  codes text NOT NULL,
                                                  usage_at_rest double precision NOT NULL,
                                                  usage_get bigint NOT NULL,
                                                  usage_put bigint NOT NULL,
                                                  usage_get_repair bigint NOT NULL,
                                                  usage_put_repair bigint NOT NULL,
                                                  usage_get_audit bigint NOT NULL,
                                                  comp_at_rest bigint NOT NULL,
                                                  comp_get bigint NOT NULL,
                                                  comp_put bigint NOT NULL,
                                                  comp_get_repair bigint NOT NULL,
                                                  comp_put_repair bigint NOT NULL,
                                                  comp_get_audit bigint NOT NULL,
                                                  surge_percent bigint NOT NULL,
                                                  held bigint NOT NULL,
                                                  owed bigint NOT NULL,
                                                  disposed bigint NOT NULL,
                                                  paid bigint NOT NULL,
                                                  PRIMARY KEY ( period, satellite_id )
                                );
CREATE TABLE payments (
                                                id bigserial NOT NULL,
                                                created_at timestamp NOT NULL,
                                                satellite_id bytea NOT NULL,
                                                period text,
                                                amount bigint NOT NULL,
                                                receipt text,
                                                notes text,
                                                PRIMARY KEY ( id )
                                        );
.exit
  1. The next database
sqlite3 /path/to/piece_expiration.db
  1. When you see the sqlite> prompt, execute this script:
CREATE TABLE piece_expirations (
                                                satellite_id       BLOB      NOT NULL,
                                                piece_id           BLOB      NOT NULL,
                                                piece_expiration   TIMESTAMP NOT NULL, -- date when it can be deleted
                                                deletion_failed_at TIMESTAMP, trash INTEGER NOT NULL DEFAULT 0,
                                                PRIMARY KEY (satellite_id, piece_id)
                                        );
CREATE TABLE versions (version int, commited_at text);
CREATE INDEX idx_piece_expirations_piece_expiration ON piece_expirations(piece_expiration);
CREATE INDEX idx_piece_expirations_deletion_failed_at ON piece_expirations(deletion_failed_at);
CREATE INDEX idx_piece_expirations_trashed
                                                ON piece_expirations(satellite_id, trash)
                                                WHERE trash = 1;
.exit
  1. The next database
sqlite3 /path/to/pricing.db
  1. When you see a sqlite> prompt, execute this script:
CREATE TABLE versions (version int, commited_at text);
CREATE TABLE pricing (
                                                satellite_id BLOB NOT NULL,
                                                egress_bandwidth_price bigint NOT NULL,
                                                repair_bandwidth_price bigint NOT NULL,
                                                audit_bandwidth_price bigint NOT NULL,
                                                disk_space_price bigint NOT NULL,
                                                PRIMARY KEY ( satellite_id )
                                        );
.exit
  1. Start the storagenode
  2. Check your logs

I did it.
Now a new error occurs.
docker log storagenode shows the following:

It looks like something else needs to be done.

  1. Stop the storagenode
  2. Make a backup of heldamount.db
  3. Execute
sqlite3 /path/to/heldamount.db
drop table paystubs;
.exit
  1. Start the storagenode
  2. Check your logs

I did it.
In addition, after similar messages, I deleted the table payments from file heldamount.db and pricing from file pricing.db.
After that, the system started up and I can see “Online” on the dashboard.
Many thanks.

In addition, I am very interested if the accumulated information is not lost?

1 Like

The data is intact, but your local stat is lost. The storage usage should be accumulated at the first start, but the past usage is lost forever.
It will not affect your payout though.

Thanks again. It’s a pleasure to work with you.

2 Likes