Negative held amount

Is this my node problem? Or something global?

Could you please check it with an

Hello,
earnings.py also show the same negative (overpaid) amount.

Then your databases got corrupted. Or you used them from the other node.

Screen Shot 2020-10-06 at 11.37.37 AM

I have 2nd node on the same machine, but have no idea how it could mix together and use other then needed db.

It’s enough to configure it with a wrong path once.

I can’t rember i’ve made such a mistake. But let’s assume i did.
Is there any way to fix it?

Let’s try to move the current version of heldamount.db to the backup and create an empty one:

  1. Stop the storagenode
  2. Move the heldamount.db to heldamount.db.bak
  3. Execute either with a local installed sqlite3 or with a docker version (you can take an example from https://support.storj.io/hc/en-us/articles/360029309111), replace the /path/to with your 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. Start the storagenode
  2. Check logs
  3. If all ok, check the dashboard

Thank you, tried, but:

sqlite3 heldamount.db
SQLite version 3.29.0 2019-07-10 17:32:03
Enter “.help” for usage hints.
sqlite> CREATE TABLE versions (version int, commited_at text);
t 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 )
);
.exitsqlite> 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 )
…> );
sqlite> 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 )
…> );
sqlite> .exit

When restarted node, it won’t start. Logs show this:

2020-10-14T07:40:30.885Z INFO db.migration.32 Create paystubs table and payments table
Error: Error creating tables for master database on storagenode: migrate: table paystubs already exists
storj.io/storj/private/migrate.SQL.Run:274
storj.io/storj/private/migrate.(*Migration).Run.func1:179
storj.io/storj/private/dbutil/txutil.withTxOnce:75
storj.io/storj/private/dbutil/txutil.WithTx:36
storj.io/storj/private/migrate.(*Migration).Run:178
storj.io/storj/storagenode/storagenodedb.(*DB).MigrateToLatest:373
main.cmdRun:184
storj.io/private/process.cleanup.func1.4:353
storj.io/private/process.cleanup.func1:371
github.com/spf13/cobra.(*Command).execute:840
github.com/spf13/cobra.(*Command).ExecuteC:945
github.com/spf13/cobra.(*Command).Execute:885
storj.io/private/process.ExecWithCustomConfig:88
storj.io/private/process.ExecCustomDebug:70
main.main:330
runtime.main:204
2020-10-14T07:40:37.767Z INFO Configuration loaded {“Location”: “/app/config/config.yaml”}
2020-10-14T07:40:37.776Z INFO Operator email {“Address”: “email@email”}
2020-10-14T07:40:37.776Z INFO Operator wallet {“Address”: “0x…”}
2020-10-14T07:40:38.672Z INFO Telemetry enabled
2020-10-14T07:40:38.683Z INFO db.migration.32 Create paystubs table and payments table
Error: Error creating tables for master database on storagenode: migrate: table paystubs already exists
storj.io/storj/private/migrate.SQL.Run:274
storj.io/storj/private/migrate.(*Migration).Run.func1:179
storj.io/storj/private/dbutil/txutil.withTxOnce:75
storj.io/storj/private/dbutil/txutil.WithTx:36
storj.io/storj/private/migrate.(*Migration).Run:178
storj.io/storj/storagenode/storagenodedb.(*DB).MigrateToLatest:373
main.cmdRun:184
storj.io/private/process.cleanup.func1.4:353
storj.io/private/process.cleanup.func1:371
github.com/spf13/cobra.(*Command).execute:840
github.com/spf13/cobra.(*Command).ExecuteC:945
github.com/spf13/cobra.(*Command).Execute:885
storj.io/private/process.ExecWithCustomConfig:88
storj.io/private/process.ExecCustomDebug:70
main.main:330
runtime.main:204

  1. Stop the storagenode
  2. Execute with a sqlite3
sqlite3 heldamount.db
  1. When you see a sqlite> prompt, execute:
insert into versions select 32, datetime() where not exists(select 1 from versions where "version" = 32);
insert into versions select 33, datetime() where not exists(select 1 from versions where "version" = 33);
insert into versions select 37, datetime() where not exists(select 1 from versions where "version" = 37);
insert into versions select 43, datetime() where not exists(select 1 from versions where "version" = 43);
.exit
  1. Start the storagenode
  2. Check logs

As the first suggestion did not worked out and the node could not run at all, i’ve moved heldamaunt.db back from and restartard node. So should i do this second suggestion on the orginial (corrupted) db, or on the new one, after making a BAK?

The second is solution for the error with a new empty database when the storagenode trying to apply migrations, which already applied.

Alexey. Node is running, log’s looks nice. I don’t have currently access to it’s web dashboard so i could not see the held amount, but will check later today, and let you know.

As always - thank you for your help! : )

P.S. Checked, everything is fine!!

1 Like