Project

General

Profile

action #35749

Ignore insert errors in limit_assets

Added by coolo about 4 years ago. Updated over 3 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Concrete Bugs
Target version:
Start date:
2018-05-02
Due date:
% Done:

0%

Estimated time:
Difficulty:
easy

Description

We have repeatedly limit_asset jobs failing due to:

   "error" => "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)=(iso, openSUSE-Leap:15.0-Staging:E-Staging-DVD-x86_64-Build131.1-Media.iso) already exists. [for Statement \"INSERT INTO assets ( name, t_created, t_updated, type) VALUES ( ?, ?, ?, ? ) RETURNING id\" with ParamValues: 1='openSUSE-Leap:15.0-Staging:E-Staging-DVD-x86_64-Build131.1-Media.iso', 2='2018-04-28 10:51:47', 3='2018-04-28 10:51:47', 4='iso'] at /usr/share/openqa/script/../lib/OpenQA/Schema/ResultSet/Assets.pm line 40\n"

This is because limit_assets tries to insert new assets - just as ISOs post does. So the insert is fine to fail - so either catch it or use postgresql ON CONFLICT DO NOTHING


Related issues

Related to openQA Project - action #109292: OSD is missing x86_64 jobs duplicate key value violates unique constraint "assets_type_name" in lib/OpenQA/Schema/ResultSet/Assets.pm line 33 within find_or_createResolved2022-03-31

History

#1 Updated by mkittler about 4 years ago

  • Status changed from New to In Progress
  • Assignee set to mkittler

#2 Updated by mkittler about 4 years ago

The test t/api/02-assets.t (line 124) should trigger this. It explicitly does an insert which violates the constraint. However, the error can not be reproduced in the test case.

Even calling the method directly like

is($t->app->db->resultset('Assets')->register('iso', $iso1)->id, $listing->[0]->{id}, 'calling register manually');

doesn't produce an error message as in the issue description. Instead, the ID of the existing entry is returned correctly.

Also, according to the documentation, the way you're using find_or_create seems correct: http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#find_or_create

So not sure what's producing the error in this case.

#3 Updated by coolo about 4 years ago

well, it's hard to reproduce a race with just one test case running. And according to the documention linked find_or_create needs to run in a transaction to be resistant to race conditions - and we're not doing that.

#4 Updated by mkittler about 4 years ago

  • Status changed from In Progress to Workable
  • Assignee deleted (mkittler)

Ah, this is about sporadic failure. Maybe we can just make it a transaction then.

I'm unassigning because it isn't part of the current sprint.

#5 Updated by mkittler almost 4 years ago

  • Status changed from Workable to In Progress
  • Assignee set to mkittler

#6 Updated by mkittler almost 4 years ago

  • Status changed from In Progress to Resolved

PR has been merged. Just reopen this if the error isn't gone, though.

#7 Updated by coolo over 3 years ago

  • Target version changed from Ready to Done

#8 Updated by mkittler 3 months ago

  • Related to action #109292: OSD is missing x86_64 jobs duplicate key value violates unique constraint "assets_type_name" in lib/OpenQA/Schema/ResultSet/Assets.pm line 33 within find_or_create added

Also available in: Atom PDF