buildbuddy-io / buildbuddy

BuildBuddy is an open source Bazel build event viewer, result store, remote cache, and remote build execution platform.

Home Page:https://buildbuddy.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`duplicate key value violates unique constraint "Invocations_pkey"`

nhurden opened this issue · comments

Occasionally BEP uploads fail with:

The Build Event Protocol upload failed: Not retrying publishBuildEvents, no more attempts left: 
status='Status{code=UNKNOWN, description=ERROR: duplicate key value violates unique constraint "Invocations_pkey" (SQLSTATE 23505), cause=null}' 
UNKNOWN: 
UNKNOWN: 
ERROR: duplicate key value violates unique constraint "Invocations_pkey" (SQLSTATE 23505) 
UNKNOWN: 
UNKNOWN: 
ERROR: duplicate key value violates unique constraint "Invocations_pkey" (SQLSTATE 23505)

(line breaks added manually)

Logs on the server side point to https://github.com/buildbuddy-io/buildbuddy/blob/v2.12.46/server/util/db/db.go#L759

Using v2.12.46 with postgres

Hey @nhurden - thanks for reporting!

Does this reproduce with latest v2.15.0?

I suspect this is an edge case we handle gracefully in MySQL, but we don't handle correctly with the Postgres driver.

cc @tempoz

Could this be related to https://github.com/buildbuddy-io/buildbuddy/blob/master/server/util/db/db_cgo.go#L28? Seems to handle MySQL and SQLite but not PostgreSQL.

That looks like a good bet!

I'll add postgres to that function; guess I missed it the first time :P

Should be fixed in the next release by: #4437