community icon indicating copy to clipboard operation
community copied to clipboard

duplicate build numbers sending concurrent webhooks

Open JordanSussman opened this issue 4 years ago • 3 comments

Description

Currently, sending webhook payloads for the same repo in quick succession can cause the error of pq: duplicate key value violates unique constraint "builds_repo_id_number_key".

Value

Vela is able to receive near concurrent webhooks without failing.

Useful Information

Steps to reproduce:

  1. Activate repo in Vela
  2. Send webhook payload in quick succession (e.g. curl -H "Content-Type: application/json" -H "X-GitHub-Event: push" -H "X-GitHub-Delivery: <id>" -X POST http://localhost:8080/webhook -d "$(cat payload.json)")

You can also sporadically reproduce the error if you attempt to quickly restart builds within the UI.

Additional output from my local docker-compose.yml setup:

postgres    | 2021-02-18 18:07:03.974 UTC [1412] ERROR:  duplicate key value violates unique constraint "builds_repo_id_number_key"
postgres    | 2021-02-18 18:07:03.974 UTC [1412] DETAIL:  Key (repo_id, number)=(1, 247) already exists.
postgres    | 2021-02-18 18:07:03.974 UTC [1412] STATEMENT:  INSERT INTO "builds" ("repo_id","number","parent","event","status","error","enqueued","created","started","finished","deploy","deploy_payload","clone","source","title","message","commit","sender","author","email","link","branch","ref","base_ref","head_ref","host","runtime","distribution") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28) RETURNING "builds"."id"
server      |
server      | (/Users/jordansussman/git/github/go-vela/server/database/build.go:384)
server      | [2021-02-18 18:07:03]  pq: duplicate key value violates unique constraint "builds_repo_id_number_key"
  1. What is the output of vela --version?

Server is utilizing 0.7.2

  1. What operating system is being used?

MacOS

JordanSussman avatar Feb 18 '21 18:02 JordanSussman