Skip to content

ServerError "23505" "duplicate key value violates unique constraint "unique_drep_distr" #2007

@ArturWieczorek

Description

@ArturWieczorek

Logs:
dbsync-stdout.txt

I ran into SNErrDbSessionErr when running automated tests on local testnet cluster with cardano-db-sync master.

Error SNErrDbSessionErr: 
 App call chain: runDbSyncTransaction at Cardano.DbSync.Default:src/Cardano/DbSync/Default.hs:59 
 DB call chain: fn:insertBulkDrepDistrPiped md:Cardano.DbSync.Era.Universal.Insert.GovAction loc:src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs:385
 ResultError (ServerError "23505" "duplicate key value violates unique constraint \"unique_drep_distr\"" (Just "Key (hash_id, epoch_no)=(6, 9) already exists.") Nothing Nothing)
 QueryError "INSERT INTO drep_distr (hash_id, amount, epoch_no, active_until)  SELECT hash_id, amount, epoch_no, active_until FROM UNNEST ($1::bigint[], $2::bigint[], $3::bigint[], $4::bigint[]) AS t(hash_id, amount, epoch_no, active_until) " ["[6, 2, 10, 4, 8, 1]","[500000000000, 500000000000, 500000000000, 500000000000, 500000000000, 3028522017294]","[9, 9, 9, 9, 9, 9]","[107, 107, 107, 107, 107, null]"]
[31m[db-sync-node:Error:144] [2025-10-15 09:36:01.34 UTC] runDbThread: Error SNErrDbSessionErr: 
 App call chain: runDbSyncTransaction at Cardano.DbSync.Default:src/Cardano/DbSync/Default.hs:59 
 DB call chain: fn:insertBulkDrepDistrPiped md:Cardano.DbSync.Era.Universal.Insert.GovAction loc:src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs:385
 ResultError (ServerError "23505" "duplicate key value violates unique constraint \"unique_drep_distr\"" (Just "Key (hash_id, epoch_no)=(6, 9) already exists.") Nothing Nothing)
 QueryError "INSERT INTO drep_distr (hash_id, amount, epoch_no, active_until)  SELECT hash_id, amount, epoch_no, active_until FROM UNNEST ($1::bigint[], $2::bigint[], $3::bigint[], $4::bigint[]) AS t(hash_id, amount, epoch_no, active_until) " ["[6, 2, 10, 4, 8, 1]","[500000000000, 500000000000, 500000000000, 500000000000, 500000000000, 3028522017294]","[9, 9, 9, 9, 9, 9]","[107, 107, 107, 107, 107, null]"]

It occurs randomly throughout the test suite, and the issue persists across test runs - looks like rollbacks could be responsible for that.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions