samson
samson copied to clipboard
Duplicate record on build
I got an error (on 2 different deploys) with:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_releases_on_project_id_and_number"
DETAIL: Key (project_id, number)=(72, 3) already exists.
: INSERT INTO "releases" ("project_id", "commit", "number", "author_id", "author_type", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"
+ 67 non-project frames
68 File "/var/www/samson/releases/1/app/models/release_service.rb" line 8 in release
69 File "/var/www/samson/releases/1/app/controllers/integrations/base_controller.rb" line 63 in find_or_create_release
70 File "/var/www/samson/releases/1/app/controllers/integrations/base_controller.rb" line 20 in create
The request was started from buildkite integration. Slightly sanitized event is:
{
"event": "build.finished",
"build": {
"id": "90827f6f-56e1-4706-8a12-e2adf73686b4",
"url": "https://api.buildkite.com/v2/organizations/.../builds/1219",
"web_url": "https://buildkite.com/.../builds/1219",
"number": 1219,
"state": "passed",
"blocked": false,
"message": "Merge pull request #269 from ...,
"commit": "0969ba12595870e21a4fdf369b5a6ded577e7f48",
"branch": "master",
"tag": null,
"source": "webhook",
"creator": {
"id": "b70c9d1f-a345-4a1c-990f-f51fce36ff5e",
"name": "...",
"email": "...",
"avatar_url": "https://www.gravatar.com/avatar/...",
"created_at": "2015-03-02 05:04:56 UTC"
},
"created_at": "2018-06-05 01:38:26 UTC",
"scheduled_at": "2018-06-05 01:38:26 UTC",
"started_at": "2018-06-05 01:43:07 UTC",
"finished_at": "2018-06-05 01:45:41 UTC",
"meta_data": {
"buildkite:git:commit": "commit 0969ba12595870e21a4fdf369b5a6ded577e7f48\nMerge: e81c28d 8b06306\nAuthor: ...\nAuthorDate: Tue Jun 5 11:38:24 2018 +1000\nCommit: GitHub <[email protected]>\nCommitDate: Tue Jun 5 11:38:24 2018 +1000\n\n Merge pull request #269 from ..."
},
"pull_request": null
},
"pipeline": {
"id": "989b955c-702e-4e10-b94f-91abbac80c63",
"url": "https://api.buildkite.com/v2/organizations/...",
"web_url": "https://buildkite.com/...",
"name": "...",
"description": ":dollar:",
"slug": "...",
"repository": "[email protected]:....git",
"branch_configuration": null,
"default_branch": "master",
"skip_queued_branch_builds": false,
"skip_queued_branch_builds_filter": null,
"cancel_running_branch_builds": false,
"cancel_running_branch_builds_filter": null,
"provider": {
"id": "github",
"settings": {
"trigger_mode": "code",
"build_pull_requests": true,
"pull_request_branch_filter_enabled": false,
"skip_pull_request_builds_for_existing_commits": true,
"build_pull_request_forks": false,
"build_tags": false,
"publish_commit_status": true,
"publish_commit_status_per_step": false,
"repository": "..."
},
"webhook_url": "https://webhook.buildkite.com/deliver/..."
},
"builds_url": "https://api.buildkite.com/v2/organizations/.../builds",
"badge_url": "https://badge.buildkite.com/....svg",
"created_at": "2017-03-27 05:12:27 UTC",
"env": {},
"scheduled_builds_count": 0,
"running_builds_count": 0,
"scheduled_jobs_count": 0,
"running_jobs_count": 4,
"waiting_jobs_count": 0,
"steps": [
{
"type": "script",
"name": ":pipeline:",
"command": "buildkite-agent pipeline upload",
"artifact_paths": "",
"branch_configuration": "",
"env": {},
"timeout_in_minutes": null,
"agent_query_rules": [
"queue=platform-docker-spot"
],
"concurrency": null,
"parallelism": null
}
]
},
"sender": {
"id": "b70c9d1f-a345-4a1c-990f-f51fce36ff5e",
"name": "..."
}
}
Version v2235 I don't really know the conditions why it happened. Happy to provide more details if needed.
check the logs if there are maybe 2 requests coming in at the same time, seems suspicious that a single request would trigger creation of 2 releases
On Thu, Jun 21, 2018 at 8:34 PM Stanisław Pitucha [email protected] wrote:
I got an error (on 2 different deploys) with:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_releases_on_project_id_and_number" DETAIL: Key (project_id, number)=(72, 3) already exists. : INSERT INTO "releases" ("project_id", "commit", "number", "author_id", "author_type", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"
- 67 non-project frames 68 File "/var/www/samson/releases/1/app/models/release_service.rb" line 8 in release 69 File "/var/www/samson/releases/1/app/controllers/integrations/base_controller.rb" line 63 in find_or_create_release 70 File "/var/www/samson/releases/1/app/controllers/integrations/base_controller.rb" line 20 in create
The request was started from buildkite integration. Slightly sanitized event is:
{ "event": "build.finished", "build": { "id": "90827f6f-56e1-4706-8a12-e2adf73686b4", "url": "https://api.buildkite.com/v2/organizations/.../builds/1219", "web_url": "https://buildkite.com/.../builds/1219", "number": 1219, "state": "passed", "blocked": false, "message": "Merge pull request #269 from ..., "commit": "0969ba12595870e21a4fdf369b5a6ded577e7f48", "branch": "master", "tag": null, "source": "webhook", "creator": { "id": "b70c9d1f-a345-4a1c-990f-f51fce36ff5e", "name": "...", "email": "...", "avatar_url": "https://www.gravatar.com/avatar/...", "created_at": "2015-03-02 05:04:56 UTC" }, "created_at": "2018-06-05 01:38:26 UTC", "scheduled_at": "2018-06-05 01:38:26 UTC", "started_at": "2018-06-05 01:43:07 UTC", "finished_at": "2018-06-05 01:45:41 UTC", "meta_data": { "buildkite:git:commit": "commit 0969ba12595870e21a4fdf369b5a6ded577e7f48\nMerge: e81c28d 8b06306\nAuthor: ...\nAuthorDate: Tue Jun 5 11:38:24 2018 +1000\nCommit: GitHub [email protected]\nCommitDate: Tue Jun 5 11:38:24 2018 +1000\n\n Merge pull request #269 from ..." }, "pull_request": null }, "pipeline": { "id": "989b955c-702e-4e10-b94f-91abbac80c63", "url": "https://api.buildkite.com/v2/organizations/...", "web_url": "https://buildkite.com/...", "name": "...", "description": ":dollar:", "slug": "...", "repository": "[email protected]:....git", "branch_configuration": null, "default_branch": "master", "skip_queued_branch_builds": false, "skip_queued_branch_builds_filter": null, "cancel_running_branch_builds": false, "cancel_running_branch_builds_filter": null, "provider": { "id": "github", "settings": { "trigger_mode": "code", "build_pull_requests": true, "pull_request_branch_filter_enabled": false, "skip_pull_request_builds_for_existing_commits": true, "build_pull_request_forks": false, "build_tags": false, "publish_commit_status": true, "publish_commit_status_per_step": false, "repository": "..." }, "webhook_url": "https://webhook.buildkite.com/deliver/..." }, "builds_url": "https://api.buildkite.com/v2/organizations/.../builds", "badge_url": "https://badge.buildkite.com/....svg", "created_at": "2017-03-27 05:12:27 UTC", "env": {}, "scheduled_builds_count": 0, "running_builds_count": 0, "scheduled_jobs_count": 0, "running_jobs_count": 4, "waiting_jobs_count": 0, "steps": [ { "type": "script", "name": ":pipeline:", "command": "buildkite-agent pipeline upload", "artifact_paths": "", "branch_configuration": "", "env": {}, "timeout_in_minutes": null, "agent_query_rules": [ "queue=platform-docker-spot" ], "concurrency": null, "parallelism": null } ] }, "sender": { "id": "b70c9d1f-a345-4a1c-990f-f51fce36ff5e", "name": "..." } }
Version v2235 I don't really know the conditions why it happened. Happy to provide more details if needed.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zendesk/samson/issues/2819, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAsZ_ig6hQpAnwi2GsM0wz22GzAcMeeks5t_GXDgaJpZM4UzF9B .