Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix constraint violation in Jobset update #576

Closed
wants to merge 1 commit into from

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Jul 16, 2018

Until now I usually get an error like this when I try to update a jobset
configuration which contains several inputs:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception:
DBD::SQLite::st execute failed: UNIQUE constraint failed:
JobsetInputAlts.project, JobsetInputAlts.jobset, JobsetInputAlts.input, JobsetInputAlts.altnr
[for Statement "INSERT INTO JobsetInputAlts ( altnr, input, jobset, project, value) VALUES ( ?, ?, ?, ?, ? )"
with ParamValues: 1=0, 2='github', 3='baumal', 4='alarm', 5='https://github.com/nixos/nixpkgs']
at /home/ma27/Projects/hydra/src/script/../lib/Hydra/Controller/Jobset.pm line 279

This happens to occur since the table JobsetInputAlts contains a
primary key over the fields project, jobset, input, altnr`. When I
alter another value (e.g. switching the state from "Enabled" to
"Disabled") the controller tries to create a new input which collides
the the primary key declaration.

To work around this, the database should check first if the input
already exists by using update_or_create.

Until now I usually get an error like this when I try to update a jobset
configuration which contains several inputs:

```
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception:
DBD::SQLite::st execute failed: UNIQUE constraint failed:
JobsetInputAlts.project, JobsetInputAlts.jobset, JobsetInputAlts.input, JobsetInputAlts.altnr
[for Statement "INSERT INTO JobsetInputAlts ( altnr, input, jobset, project, value) VALUES ( ?, ?, ?, ?, ? )"
with ParamValues: 1=0, 2='github', 3='baumal', 4='alarm', 5='https://github.com/nixos/nixpkgs']
at /home/ma27/Projects/hydra/src/script/../lib/Hydra/Controller/Jobset.pm line 279
```

This happens to occur since the table `JobsetInputAlts` contains a
primary key over the fields `project`, `jobset`, `input, `altnr`. When I
alter another value (e.g. switching the state from "Enabled" to
"Disabled") the controller tries to create a new input which collides
the the primary key declaration.

To work around this, the database should check first if the input
already exists by using `update_or_create`.
@Ma27
Copy link
Member Author

Ma27 commented Apr 4, 2020

I can't reproduce the issues on latest Hydra anymore -> closing.

@Ma27 Ma27 closed this Apr 4, 2020
@Ma27 Ma27 deleted the fix-jobset-update branch April 4, 2020 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant