# Negative held amount

**URL:** <https://forum.storj.io/t/negative-held-amount/9488>\
**Category:** troubleshooting\
**Tags:** payouts\
**Created:** [October 4, 2020, 4:32am UTC](https://forum.storj.io/t/negative-held-amount/9488 "2020-10-04T04:32:50Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 4, 2020, 4:32am UTC](https://forum.storj.io/t/negative-held-amount/9488/1 "2020-10-04T04:32:51Z")

</div>

Is this my node problem? Or something global?

 ![image](https://storj-s3.bcdn.literatehosting.net/original/2X/c/c99cb054976e86885945195547f3b4ed52c2e47c.jpeg)

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [October 4, 2020, 9:02am UTC](https://forum.storj.io/t/negative-held-amount/9488/2 "2020-10-04T09:02:14Z")

</div>

Could you please check it with an

> [@Earnings calculator (Detailed earnings info and health status of your node, including vetting progress and garbage collection status)](https://forum.storj.io/t/earnings-calculator-update-2020-09-15-v9-4-0-uptime-is-back-now-compatible-with-v1-12-and-more-verbose-warnings/1794):
>
> Latest version @ 2025-12-18: v14.3.0 - Consider minimum vetting time for vetting progress I made this calculator to provide payout information and be used as an extension of the dashboard functionality already provided by Storj. Storj Earnings Calculator Earnings calculation script for Storj storagenodes Prerequisites Python is required to run this script. This script was tested on Windows 10 and Linux, with Python 3.7. Other OS’s and versions will likely also work. Warning If you are runnin…

---

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 5, 2020, 8:28am UTC](https://forum.storj.io/t/negative-held-amount/9488/3 "2020-10-05T08:28:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [October 5, 2020, 8:49am UTC](https://forum.storj.io/t/negative-held-amount/9488/4 "2020-10-05T08:49:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 6, 2020, 8:45am UTC](https://forum.storj.io/t/negative-held-amount/9488/5 "2020-10-06T08:45:55Z")

</div>

![Screen Shot 2020-10-06 at 11.37.37 AM](https://lc-storj.ams3.digitaloceanspaces.com/original/2X/f/f5e1114984b914c48aa1f3c5b005d12dfd776084.png)

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

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [October 6, 2020, 7:13pm UTC](https://forum.storj.io/t/negative-held-amount/9488/6 "2020-10-06T19:13:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 7, 2020, 7:38am UTC](https://forum.storj.io/t/negative-held-amount/9488/7 "2020-10-07T07:38:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [October 9, 2020, 9:50pm UTC](https://forum.storj.io/t/negative-held-amount/9488/8 "2020-10-09T21:50:28Z")

</div>

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](https://support.storj.io/hc/en-us/articles/360029309111)), replace the `/path/to` with your actual path:

```auto
sqlite3 /path/to/heldamount.db 

```

1. When you see a `sqlite>` prompt execute this script:

```auto
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

---

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 14, 2020, 7:42am UTC](https://forum.storj.io/t/negative-held-amount/9488/9 "2020-10-14T07:42:24Z")

</div>

> [@Alexey](#):
>
> `heldamount.db `

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](http://storj.io/storj/private/migrate.SQL.Run:274)  
[storj.io/storj/private/migrate.(\*Migration).Run.func1:179](http://storj.io/storj/private/migrate.(*Migration).Run.func1:179)  
[storj.io/storj/private/dbutil/txutil.withTxOnce:75](http://storj.io/storj/private/dbutil/txutil.withTxOnce:75)  
[storj.io/storj/private/dbutil/txutil.WithTx:36](http://storj.io/storj/private/dbutil/txutil.WithTx:36)  
[storj.io/storj/private/migrate.(\*Migration).Run:178](http://storj.io/storj/private/migrate.(*Migration).Run:178)  
[storj.io/storj/storagenode/storagenodedb.(\*DB).MigrateToLatest:373](http://storj.io/storj/storagenode/storagenodedb.(*DB).MigrateToLatest:373)  
main.cmdRun:184  
[storj.io/private/process.cleanup.func1.4:353](http://storj.io/private/process.cleanup.func1.4:353)  
[storj.io/private/process.cleanup.func1:371](http://storj.io/private/process.cleanup.func1:371)  
[github.com/spf13/cobra.(\*Command).execute:840](http://github.com/spf13/cobra.(*Command).execute:840)  
[github.com/spf13/cobra.(\*Command).ExecuteC:945](http://github.com/spf13/cobra.(*Command).ExecuteC:945)  
[github.com/spf13/cobra.(\*Command).Execute:885](http://github.com/spf13/cobra.(*Command).Execute:885)  
[storj.io/private/process.ExecWithCustomConfig:88](http://storj.io/private/process.ExecWithCustomConfig:88)  
[storj.io/private/process.ExecCustomDebug:70](http://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](http://storj.io/storj/private/migrate.SQL.Run:274)  
[storj.io/storj/private/migrate.(\*Migration).Run.func1:179](http://storj.io/storj/private/migrate.(*Migration).Run.func1:179)  
[storj.io/storj/private/dbutil/txutil.withTxOnce:75](http://storj.io/storj/private/dbutil/txutil.withTxOnce:75)  
[storj.io/storj/private/dbutil/txutil.WithTx:36](http://storj.io/storj/private/dbutil/txutil.WithTx:36)  
[storj.io/storj/private/migrate.(\*Migration).Run:178](http://storj.io/storj/private/migrate.(*Migration).Run:178)  
[storj.io/storj/storagenode/storagenodedb.(\*DB).MigrateToLatest:373](http://storj.io/storj/storagenode/storagenodedb.(*DB).MigrateToLatest:373)  
main.cmdRun:184  
[storj.io/private/process.cleanup.func1.4:353](http://storj.io/private/process.cleanup.func1.4:353)  
[storj.io/private/process.cleanup.func1:371](http://storj.io/private/process.cleanup.func1:371)  
[github.com/spf13/cobra.(\*Command).execute:840](http://github.com/spf13/cobra.(*Command).execute:840)  
[github.com/spf13/cobra.(\*Command).ExecuteC:945](http://github.com/spf13/cobra.(*Command).ExecuteC:945)  
[github.com/spf13/cobra.(\*Command).Execute:885](http://github.com/spf13/cobra.(*Command).Execute:885)  
[storj.io/private/process.ExecWithCustomConfig:88](http://storj.io/private/process.ExecWithCustomConfig:88)  
[storj.io/private/process.ExecCustomDebug:70](http://storj.io/private/process.ExecCustomDebug:70)  
main.main:330  
runtime.main:204

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [October 14, 2020, 8:17am UTC](https://forum.storj.io/t/negative-held-amount/9488/10 "2020-10-14T08:17:28Z")

</div>

1. Stop the storagenode
2. Execute with a sqlite3

```auto
sqlite3 heldamount.db

```

1. When you see a `sqlite>` prompt, execute:

```auto
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

---

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 14, 2020, 8:21am UTC](https://forum.storj.io/t/negative-held-amount/9488/11 "2020-10-14T08:21:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [October 14, 2020, 8:27am UTC](https://forum.storj.io/t/negative-held-amount/9488/12 "2020-10-14T08:27:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![node1](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/node1/32/6289_2.png) [@node1](https://forum.storj.io/u/node1)\
**Post date:** [October 14, 2020, 8:32am UTC](https://forum.storj.io/t/negative-held-amount/9488/13 "2020-10-14T08:32:15Z")

</div>

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!!
