insights: commit indexer fails for repository due to duplicate key violation
Created by: chwarwick
The follow error has been reported:
t=2022-04-26T19:17:05+0000 lvl=eror msg="unable to update commit index repo_id: {REPO_ID}: error saving commit for repo_id: {REPO_ID} commit_id {COMMIT}: ERROR: duplicate key value violates unique constraint \"commit_index_pkey\" (SQLSTATE 23505)"
Commit index table schema:
create table commit_index
(
committed_at timestamp with time zone not null,
repo_id integer not null,
commit_bytea bytea not null,
indexed_at timestamp default CURRENT_TIMESTAMP,
debug_field text,
primary key (committed_at, repo_id, commit_bytea)
)```
This error will block the insights indexer from indexing additional commits for the repository and will cause insights to fall back to uncompressed query plans.