Project

General

Profile

Actions

action #35749

closed

Ignore insert errors in limit_assets

Added by coolo over 6 years ago. Updated about 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Regressions/Crashes
Target version:
Start date:
2018-05-02
Due date:
% Done:

0%

Estimated time:

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 1 (0 open1 closed)

Related to openQA Project (public) - 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_createResolvedmkittler2022-03-31

Actions
Actions #1

Updated by mkittler over 6 years ago

  • Status changed from New to In Progress
  • Assignee set to mkittler
Actions #2

Updated by mkittler over 6 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.

Actions #3

Updated by coolo over 6 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.

Actions #4

Updated by mkittler over 6 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.

Actions #5

Updated by mkittler over 6 years ago

  • Status changed from Workable to In Progress
  • Assignee set to mkittler
Actions #6

Updated by mkittler over 6 years ago

  • Status changed from In Progress to Resolved

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

Actions #7

Updated by coolo about 6 years ago

  • Target version changed from Ready to Done
Actions #8

Updated by mkittler over 2 years 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
Actions

Also available in: Atom PDF