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

insert or update on tables "pool_owner" and "tx_out" violates foreign key constraints #1222

Closed
mkoura opened this issue Aug 8, 2022 · 1 comment · Fixed by #1246
Closed
Labels
bug Something isn't working

Comments

@mkoura
Copy link
Contributor

mkoura commented Aug 8, 2022

OS
Fedora 35

Versions
The db-sync version: 13.0.4-rc1
PostgreSQL version: 14.4

Build/Install Method
The method you use to build or install cardano-db-sync: nix

Run method
The method you used to run cardano-db-sync (eg Nix/Docker/systemd/none): none

Additional context
Add any other context about the problem here.

Problem Report
I've run into this while testing db-sync 13.0.4-rc1 together with node 1.35.3-rc1. For some testruns, in a test that creates a stake pool and delegates stake address in the same single transaction we get following errors:

E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node:Error:588] [2022-08-07 02:38:41.45 UTC] runDBThread: DbInsertException "PoolOwner" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"pool_owner\" violates foreign key constraint \"pool_owner_addr_id_fkey\"", sqlErrorDetail = "Key (addr_id)=(12) is not present in table \"stake_address\".", sqlErrorHint = ""})
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node:Error:580] [2022-08-07 02:38:41.45 UTC] ChainSyncWithBlocksPtcl: DbInsertException "PoolOwner" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"pool_owner\" violates foreign key constraint \"pool_owner_addr_id_fkey\"", sqlErrorDetail = "Key (addr_id)=(12) is not present in table \"stake_address\".", sqlErrorHint = ""})
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node.Subscription:Error:576] [2022-08-07 02:38:41.45 UTC] Identity Application Exception: LocalAddress "/home/martink/Source/repos/cardano-node3/state-cluster8/bft1.socket" DbInsertException "PoolOwner" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"pool_owner\" violates foreign key constraint \"pool_owner_addr_id_fkey\"", sqlErrorDetail = "Key (addr_id)=(12) is not present in table \"stake_address\".", sqlErrorHint = ""})
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node.ErrorPolicy:Error:6] [2022-08-07 02:38:41.45 UTC] IP LocalAddress "/home/martink/Source/repos/cardano-node3/state-cluster8/bft1.socket" ErrorPolicyUnhandledApplicationException (DbInsertException "PoolOwner" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"pool_owner\" violates foreign key constraint \"pool_owner_addr_id_fkey\"", sqlErrorDetail = "Key (addr_id)=(12) is not present in table \"stake_address\".", sqlErrorHint = ""}))
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node:Error:688] [2022-08-07 02:38:42.65 UTC] runDBThread: DbInsertException "TxOut" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"tx_out\" violates foreign key constraint \"tx_out_stake_address_id_fkey\"", sqlErrorDetail = "Key (stake_address_id)=(10) is not present in table \"stake_address\".", sqlErrorHint = ""})
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node:Error:680] [2022-08-07 02:38:42.65 UTC] ChainSyncWithBlocksPtcl: DbInsertException "TxOut" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"tx_out\" violates foreign key constraint \"tx_out_stake_address_id_fkey\"", sqlErrorDetail = "Key (stake_address_id)=(10) is not present in table \"stake_address\".", sqlErrorHint = ""})
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node.Subscription:Error:676] [2022-08-07 02:38:42.65 UTC] Identity Application Exception: LocalAddress "/home/martink/Source/repos/cardano-node3/state-cluster8/bft1.socket" DbInsertException "TxOut" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"tx_out\" violates foreign key constraint \"tx_out_stake_address_id_fkey\"", sqlErrorDetail = "Key (stake_address_id)=(10) is not present in table \"stake_address\".", sqlErrorHint = ""})
E
E       /home/martink/Source/repos/cardano-node3/state-cluster8/dbsync.stdout: [db-sync-node.ErrorPolicy:Error:6] [2022-08-07 02:38:42.65 UTC] IP LocalAddress "/home/martink/Source/repos/cardano-node3/state-cluster8/bft1.socket" ErrorPolicyUnhandledApplicationException (DbInsertException "TxOut" (SqlError {sqlState = "23503", sqlExecStatus = FatalError, sqlErrorMsg = "insert or update on table \"tx_out\" violates foreign key constraint \"tx_out_stake_address_id_fkey\"", sqlErrorDetail = "Key (stake_address_id)=(10) is not present in table \"stake_address\".", sqlErrorHint = ""}))

and the stake pool data is not inserted into db.

I'll update with more details.

@mkoura mkoura added the bug Something isn't working label Aug 8, 2022
@kderme
Copy link
Contributor

kderme commented Aug 9, 2022

@mkoura Any chance there was there any rollback before this happened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants