IntersectMBO / cardano-db-sync

A component that follows the Cardano chain and stores blocks and transactions in PostgreSQL
Apache License 2.0
290 stars 160 forks source link

db-sync-node.ErrorPolicy:Error and db-sync-node.Subscription:Error #1368

Closed zhy827827 closed 1 year ago

zhy827827 commented 1 year ago

Ask a question version: inputoutput/cardano-db-sync:13.1.0.2

Up export NETWORK=mainnet && docker pull inputoutput/cardano-graphql-server:8.0.0-${NETWORK} && docker pull inputoutput/cardano-graphql-background:8.0.0-${NETWORK} && docker pull inputoutput/cardano-graphql-hasura:8.0.0 && docker pull cardanosolutions/cardano-node-ogmios:v5.6.0_1.35.5-${NETWORK} && RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/13.1/db-sync-snapshot-schema-13.1-block-8400235-x86_64.tgz docker compose up -d && docker compose logs -f

There are several error log messages: 1、db-sync-node:Error: sqlErrorDetail = "Key (id)=(136488540) already exists.", sqlErrorHint = ""} 2、db-sync-node.Subscription:Error:Identity Application Exception: LocalAddress "/node-ipc/node.socket" DbInsertException "Many Rewards" 3、db-sync-node.ErrorPolicy:Error:6 duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488540) already exists.", sqlErrorHint = ""}

Full log

[db-sync-node:Info:691974] [2023-02-27 09:47:10.18 UTC] Received block which is not in the db with HeaderFields {headerFieldSlot = SlotNo 85496219, headerFieldBlockNo = BlockNo 8431200, headerFieldHash = 6a5e61c33f15c09588af2aa506031a26fd1082c29bc2146f0a895aa86998f966}. Time to restore consistency. [db-sync-node:Error:691974] [2023-02-27 09:47:10.19 UTC] runDBThread: DbInsertException "Many Rewards" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488517) already exists.", sqlErrorHint = ""}) [db-sync-node:Error:691966] [2023-02-27 09:47:10.19 UTC] ChainSyncWithBlocksPtcl: DbInsertException "Many Rewards" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488517) already exists.", sqlErrorHint = ""}) [db-sync-node.Mux:Info:691963] [2023-02-27 09:47:10.19 UTC] Bearer on ConnectionId {localAddress = LocalAddress "", remoteAddress = LocalAddress "/ipc/node.socket"} event: State: Dead [db-sync-node.Mux:Notice:691963] [2023-02-27 09:47:10.19 UTC] Bearer on ConnectionId {localAddress = LocalAddress "", remoteAddress = LocalAddress "/ipc/node.socket"} event: Miniprotocol MiniProtocolNum 5 InitiatorDir terminated with exception DbInsertException "Many Rewards" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488517) already exists.", sqlErrorHint = ""}) [db-sync-node.Subscription:Error:691962] [2023-02-27 09:47:10.19 UTC] Identity Application Exception: LocalAddress "/node-ipc/node.socket" DbInsertException "Many Rewards" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488517) already exists.", sqlErrorHint = ""}) [db-sync-node.ErrorPolicy:Error:6] [2023-02-27 09:47:10.19 UTC] IP LocalAddress "/node-ipc/node.socket" ErrorPolicyUnhandledApplicationException (DbInsertException "Many Rewards" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488517) already exists.", sqlErrorHint = ""})) [db-sync-node.Subscription:Notice:56] [2023-02-27 09:47:11.48 UTC] Identity Restarting Subscription after 1.347161491s desired valency 1 current valency 0

==================================================================================== curl --ssl-no-revoke -X POST -H "Content-Type: application/json" -d '{"query": "{ cardanoDbMeta { initialized syncPercentage }}"}' http://localhost:3200/graphql |jq

100 130 100 70 100 60 2916 2500 --:--:-- --:--:-- --:--:-- 5416 { "data": { "cardanoDbMeta": { "initialized": true, "syncPercentage": 99.5 } } }

====================================================================== curl -X POST -H "Content-Type: application/json" -d '{"query": "{ cardano { tip { number slotNo epoch { number } } } }"}' http://localhost:3200/graphql |jq

{ "data": { "cardano": { "tip": { "number": 8431199, "slotNo": "85496195", "epoch": { "number": 395 } } } } }

syncPercentage always 99.5 "number": 8431199,The initialization has not been completed.How to solve this issues?

erikd commented 1 year ago

This:

[db-sync-node:Error:691966] [2023-02-27 09:47:10.19 UTC] ChainSyncWithBlocksPtcl: DbInsertException "Many Rewards" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint "reward_pkey"", sqlErrorDetail = "Key (id)=(136488517) already exists.", sqlErrorHint = ""})

Is a fatal error and the by far most common cause is that the schema in Postgres does not match the schema in the cardano-db-sync executable.

zhy827827 commented 1 year ago

So what should I do? is this docker images version inputoutput/cardano-db-sync:13.1.0.2 not match?

erikd commented 1 year ago

Sorry, I know nothing about docker. Maybe try:

zhy827827 commented 1 year ago

I've tried all that

erikd commented 1 year ago

Sorry, I do not know Docker. Someone else will know it.

ghostbuster91 commented 1 year ago

@zhy827827 Could you show your docker-compose file? I wonder how is the postgres setup.

Also please format the content of your issue using code blocks. e.g.

curl --ssl-no-revoke -X POST -H "Content-Type: application/json" -d '{"query": "{ cardanoDbMeta { initialized syncPercentage }}"}' http://localhost:3200/graphql |jq

100 130 100 70 100 60 2916 2500 --:--:-- --:--:-- --:--:-- 5416
{
  "data": {
    "cardanoDbMeta": {
    "initialized": true,
    "syncPercentage": 99.5
   }
  }
}
zhy827827 commented 1 year ago

@ghostbuster91 I have solved this issues.