Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

value for domain lovelace violates check constraint "lovelace_check" #351

Closed
mmahut opened this issue Oct 17, 2020 · 2 comments
Closed

value for domain lovelace violates check constraint "lovelace_check" #351

mmahut opened this issue Oct 17, 2020 · 2 comments

Comments

@mmahut
Copy link

mmahut commented Oct 17, 2020

On the mainnet, just after slot height 4830407, cardano-db-sync is stuck with following:

Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Info:215] [2020-10-17 12:02:43.56 UTC] Starting chainSyncClient
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Info:215] [2020-10-17 12:02:43.64 UTC] Cardano.Db tip is at slot 11369248, block 4830407
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Info:220] [2020-10-17 12:02:43.64 UTC] Running DB thread
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Info:220] [2020-10-17 12:02:43.65 UTC] Rolling back to slot 11369248, hash c847d4ffc835132dcfc07c3ff1e10c8090cdaaf9c05bea5a0b9132470aec64ba
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Info:220] [2020-10-17 12:02:43.65 UTC] Deleting blocks numbered: []
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Error:220] [2020-10-17 12:02:43.68 UTC] Bad pledge amount: 9999372036855000000 > maxLovelace. See https://github.com/input-output-hk/cardano-ledger-specs/issues/1551
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Error:220] [2020-10-17 12:02:43.68 UTC] runDBThread: DbInsertException "PoolUpdate" (SqlError {sqlState = "23514", sqlExecStatus = FatalError, sqlErrorMsg = "value for domain lovelace violates check constraint \"lovelace_check\"", sqlErrorDetail = "", sqlErrorHint = ""})
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node:Error:215] [2020-10-17 12:02:43.68 UTC] ChainSyncWithBlocksPtcl: DbInsertException "PoolUpdate" (SqlError {sqlState = "23514", sqlExecStatus = FatalError, sqlErrorMsg = "value for domain lovelace violates check constraint \"lovelace_check\"", sqlErrorDetail = "", sqlErrorHint = ""})
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node.Subscription:Error:211] [2020-10-17 12:02:43.68 UTC] [String "Application Exception: LocalAddress {getFilePath = \"/run/cardano-node/node.socket\"} DbInsertException \"PoolUpdate\" (SqlError {sqlState = \"23514\", sqlExecStatus = FatalError, sqlErrorMsg = \"value for domain lovelace violates check constraint \\\"lovelace_check\\\"\", sqlErrorDetail = \"\", sqlErrorHint = \"\"})",String "SubscriptionTrace"]
Oct 17 12:02:43  g71fl8m54rmr7f59qilbrv2r4b389d4n-cardano-db-sync[9243]: [db-sync-node.ErrorPolicy:Error:4] [2020-10-17 12:02:43.68 UTC] [String "ErrorPolicyUnhandledApplicationException (DbInsertException \"PoolUpdate\" (SqlError {sqlState = \"23514\", sqlExecStatus = FatalError, sqlErrorMsg = \"value for domain lovelace violates check constraint \\\"lovelace_check\\\"\", sqlErrorDetail = \"\", sqlErrorHint = \"\"}))",String "ErrorPolicyTrace",String "LocalAddress {getFilePath = \"/run/cardano-node/node.socket\"}"]

As a workaround, removing the constraint check seems to be a workaround, however, I'm sure it was in place for a good reason.

psql> ALTER DOMAIN lovelace DROP CONSTRAINT lovelace_check;

@mmahut mmahut changed the title value for domain lovelace violates check constraint \\\"lovelace_check\\\" value for domain lovelace violates check constraint "lovelace_check" Oct 17, 2020
@erikd
Copy link
Contributor

erikd commented Oct 17, 2020

😢 Yeah, this is disappointing. It looks like pool_update.fixed_cost amount can be > maxLovelace. I thought the ledger would guard against this nonsensical value but since it does not guard against pool_update.pledge being sane (IntersectMBO/cardano-ledger#1551) perhaps this is not surprising.

Dropping that lovelace constraint is a good temporary workaround, but a real fix is coming to master. However, even when that fix is on master it is probably not a good idea to switch because master has a large collection of other stuff that requires the db to be dropped and resynced and there is at least one more change like that coming to master, before the next release.

erikd added a commit that referenced this issue Oct 17, 2020
It seems the ledger accepts nonsensical values for 'pool_update.fixed_cost'
like a value greater than max Lovelace. That means we need to handle it
too :-(.

Closes: #351
@erikd
Copy link
Contributor

erikd commented Oct 18, 2020

Now we get a warning:

Bad fixed cost amount: 9223372036855000000 > maxLovelace. See
     https://github.com/input-output-hk/cardano-db-sync/issues/351

and db-sync keeps on running (the bad value is warned about and inserted into the database).

@erikd erikd closed this as completed in 5f4c924 Oct 18, 2020
erikd added a commit that referenced this issue Oct 20, 2020
It seems the ledger accepts nonsensical values for 'pool_update.fixed_cost'
like a value greater than max Lovelace. That means we need to handle it
too 😢.

Closes: #351
erikd added a commit that referenced this issue Oct 20, 2020
This is a workaround fix for:

   #351

This fix will not require the database to be re-synced, but will result
in some bad values being display as negative value.
erikd added a commit that referenced this issue Oct 20, 2020
This is a workaround fix for:

   #351

This fix will not require the database to be re-synced, but will result
in some bad values being display as negative value.
erikd added a commit that referenced this issue Oct 21, 2020
This is a workaround fix for:

   #351

This fix will not require the database to be re-synced, but will result
in some bad values being display as negative value.

Also includes a fix for the first stage of the schema migrations.
erikd added a commit that referenced this issue Oct 21, 2020
This is a workaround fix for:

   #351

This fix will not require the database to be re-synced, but will result
in some bad values being display as negative value.

Also includes a fix for the first stage of the schema migrations.
erikd added a commit that referenced this issue Oct 21, 2020
This is a workaround fix for:

   #351

This fix will not require the database to be re-synced, but will result
in some bad values being display as negative value.

Also includes a fix for the first stage of the schema migrations.
erikd added a commit that referenced this issue Oct 21, 2020
This is a workaround fix for:

   #351

This fix will not require the database to be re-synced, but will result
in some invalid values for the 'fixed_cost' field of the 'pool_update'
table being display as negative value.

The constraint will be droppped only if it exists (eg someone had previously
dropped in manually).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants