Actions
action #157912
closedScheduling a product can fail on asset creation because unique constraint is violated
Start date:
2024-03-25
Due date:
% Done:
0%
Estimated time:
Tags:
Description
Observation¶
{
"failed_job_info": [
{
"error_message": "DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: duplicate key value violates unique constraint \"assets_type_name\"\nDETAIL: Key (type, name)=(hdd, autoyast_SLES-12-SP5-x86_64-create_hdd_yast_maintenance_desktop-Build20240324-1.qcow2) already exists. [for Statement \"INSERT INTO assets ( name, t_created, t_updated, type) VALUES ( ?, ?, ?, ? ) RETURNING id\" with ParamValues: 1='autoyast_SLES-12-SP5-x86_64-create_hdd_yast_maintenance_desktop-Build20240324-1.qcow2', 2='2024-03-24 20:07:45', 3='2024-03-24 20:07:45', 4='hdd'] at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/Jobs.pm line 1535\n",
"job_name": "migr_sles12sp5_"
},
…
{
"error_messages": [
"DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: current transaction is aborted, commands ignored until end of transaction block [for Statement \"INSERT INTO job_dependencies ( child_job_id, dependency, parent_job_id) VALUES ( ?, ?, ? )\" with ParamValues: 1='13854606', 2='1', 3='13854599'] at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/ScheduledProducts.pm line 721\n"
],
"job_id": 13854599
}
],
"notes": [
"Transaction failed: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: current transaction is aborted, commands ignored until end of transaction block [for Statement \"INSERT INTO job_dependencies ( child_job_id, dependency, parent_job_id) VALUES ( ?, ?, ? )\" with ParamValues: 1='13854606', 2='1', 3='13854599'] at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/ScheduledProducts.pm line 721\n"
],
"successful_job_ids": []
See https://openqa.suse.de/admin/productlog?id=2081528 and https://suse.slack.com/archives/C02CANHLANP/p1711363172886899
Acceptance criteria¶
- AC1: When scheduling a product openQA doesn't run into errors like "duplicate key value violates unique constraint", even when the same asset is registered concurrently.
Suggestions¶
- Replace
my $asset = $assets->find_or_create($asset_info);
(currently at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/Jobs.pm line 1535) with raw SQL usingON CONFLICT DO NOTHING
. - Run e.g.
t/api/04-jobs.t
to test the changes.
Updated by okurz 9 months ago
- Status changed from Feedback to Resolved
https://github.com/os-autoinst/openQA/pull/5549 merged. Would be quite hard to trigger this in production so unless we receive an alert we don't need to do anything more here.
Actions