question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unique Constraint Error when adding workflows via GitHub Apps

See original GitHub issue

Describe the bug In a local dev build, I’m getting a constraint error when workflows get added from one .dockstore.yml

Curiously, the workflows still end up showing up afterwards in My Workflows. I don’t know why it didn’t rollback.

To Reproduce Steps to reproduce the behavior:

  1. Fork https://github.com/coverbeck/viral-pipelines
  2. Do a push for branch dockstore-test (simulated in this case with a local build)
  3. See error
  4. Go to My Workflows, you’ll see many <username>/viral-pipelines workflows (the .dockstore.yml defines many)

Expected behavior Ideally, there should be no error.

If there is something legit that is causing the error (?), we should try to catch it in Java code instead of letting Postgres catch it.

Screenshots GitHub App Logs show both success and failure.

Screen Shot 2021-10-18 at 8 57 28 AM

Additional context

I did this commit c877e35fdf3cbb9b8618b20983e88609bf9ea019.

Somewhat concerned there is something in my setup that is causing this.

127.0.0.1 - - [18/Oct/2021:15:44:37 +0000] "POST /workflows/github/release HTTP/1.1" 204 0 "http://localhost:4200/api/static/swagger-ui/index.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:93.0) Gecko/20100101 Firefox/93.0" 183997
WARN  [2021-10-18 15:44:37,744] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: SQL Error: 0, SQLState: 23505
ERROR [2021-10-18 15:44:37,744] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR: duplicate key value violates unique constraint "full_workflow_name"→  Detail: Key (sourcecontrol, organization, repository, workflowname)=(github.com, coverbeck, viral-pipelines, align_and_count_multiple_report) already exists.
INFO  [2021-10-18 15:44:37,901] io.dockstore.webservice.helpers.GitHubSourceCodeRepo: Performing GitHub release for repository: coverbeck/viral-pipelines, user: coverbeck, and git reference: refs/heads/dockstore-test failed. Attempt  had a starting rate limit of 6356 and ending rate limit of 6343
ERROR [2021-10-18 15:44:37,914] io.dockstore.webservice.resources.AbstractWorkflowResource: User coverbeck: Unhandled error while handling push event for repository coverbeck/viral-pipelines and reference refs/heads/dockstore-test→org.hibernate.exception.ConstraintViolationException: could not execute statement
! org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "full_workflow_name"
!   Detail: Key (sourcecontrol, organization, repository, workflowname)=(github.com, coverbeck, viral-pipelines, align_and_count_multiple_report) already exists.
! at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2552)
! at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2284)
! at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:322)
! at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
! at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
! at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164)
! at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:130)
! at jdk.internal.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
! at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
! at java.base/java.lang.reflect.Method.invoke(Method.java:566)
! at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:118)
! at com.sun.proxy.$Proxy195.executeUpdate(Unknown Source)
! at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
! ... 86 common frames omitted
! Causing: org.hibernate.exception.ConstraintViolationException: could not execute statement
! at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:109)
! at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
! at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
! at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
! at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
! at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3379)
! at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3906)
! at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:107)
! at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
! at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
! at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
! at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
! at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:344)
! at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:57)
! at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
! at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1356)
! at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1436)
! at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
! at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
! ... 72 common frames omitted
! Causing: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
! at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
! at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1626)
! at org.hibernate.query.internal.AbstractProducedQuery.uniqueResult(AbstractProducedQuery.java:1659)
! at io.dropwizard.hibernate.AbstractDAO.uniqueResult(AbstractDAO.java:151)
! at io.dockstore.webservice.jdbi.WorkflowVersionDAO.getWorkflowVersionByWorkflowIdAndVersionName(WorkflowVersionDAO.java:49)
! at io.dockstore.webservice.resources.AbstractWorkflowResource.addDockstoreYmlVersionToWorkflow(AbstractWorkflowResource.java:615)
! at io.dockstore.webservice.resources.AbstractWorkflowResource.createBioWorkflowsAndVersionsFromDockstoreYml(AbstractWorkflowResource.java:481)
! at io.dockstore.webservice.resources.AbstractWorkflowResource.githubWebhookRelease(AbstractWorkflowResource.java:354)

┆Issue is synchronized with this Jira Story ┆friendlyId: DOCK-1952 ┆sprint: Backlog ┆taskType: Story

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
coverbeckcommented, Oct 26, 2021

@denis-yuen Just tried with off commit 769b1bcaf9070831d9b97b03fcef2a6e846e0f0a on develop, and I got a 418, but I think that’s OK because it’s a code for the lambda.

0reactions
coverbeckcommented, Oct 27, 2021

Good news: there is no bug in the web server

Embarrassing news: I had invoked the endpoint via Swagger in the browser, and because the endpoint took a while to finish executing, either Swagger or the browser (I didn’t bother to figure out which) retried the endpoint.

  1. Endpoint invoked
  2. Endpoint invoked a second time
  3. 1 finishes
  4. 2 finishes but gets a constraint error because the first invocation already created the workflows.

Switched to curl and it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Unique constraint failed on the (not available) #10829
In my case the issue was that I was doing a call to updateMany with two values with the same id (a violation...
Read more >
Unique constraint error inside a transaction throws unparsed ...
While trying to auto-generate slugs for user-made pages at Copyfolio, we noticed that unique constraint violation errors aren't caught properly inside a prisma....
Read more >
Using the @unique constraint gives an error when Hasura ...
From what I see, the error that Hasura gives is because the index is being created with a "." instead of "_", and...
Read more >
Unique constraint failed during `$transaction([deleteMany ...
Bug description I have a prisma transaction which first runs a deleteMany operations followed by a createMany operation.
Read more >
ERROR: duplicate key value violates unique constraint ...
Hello, In some specific cases, when user tries to login on a application through Keycloak the user receives this error message on the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found