Why might we see "event Id already registered" with DAML for PostgreSQL Community?

Hi all,

We’re seeing an odd error message from our ledger during testing, where it is stating a uniqueness constraint violation for participant_events_pkey and as a result is unable to persist the entry, full error is below.

We’re not completely able to match up the request to this error at this time, we’re still investigating other unexpected results that came out of out testing, but we’re hoping that some information regarding this error might provide a bit more context around what actually happened. Any information about why we might receive this error would be greatly appreciated!

2021-11-18 12:49:56,627 UTC level=ERROR [daml.index.db.threadpool.connection.sandbox-8] c.d.p.s.s.l.s.SqlLedger: Failed to persist entry with offset: 0000000000000018 (context: {submissionTime=2021-11-18T12:49:56.589955Z, applicationId=my_application, deduplicateUntil=2021-11-19T12:49:56.589957Z, participantId=my-participant, actAs=MyParty, commandId=iLjjmazp5198165649947954, workflowId=abc123, ledgerTime=2021-11-18T12:49:56.589955Z}) 
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "participant_events_pkey"
  Detail: Key (event_id)=(#0000000000000018:0) already exists.
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)

Hi @lashenhurst, which ledger and which version are you using?

The only thing I can think of looking at the error is that you could be using two Daml Driver for PostgreSQL instances against a single PostgreSQL database. Sounds like a possibility during testing, spinning up a single PostgreSQL instance and running tests concurrently on that.

Is it Daml Driver for PostgreSQL 1.13.x?

That’s not impossible, I’ll double check the configuration with colleagues, thanks for the tip!

It’s version 1.11.1

Could we also see this error with a single Daml Driver for PostgreSQL instance if the same command was sent twice within a few milliseconds?

I don’t think that’s possible, modulo bugs. Are you sure that’s the case? Can you provide a minimal repro?