action #35749

Ignore insert errors in limit_assets

Added by coolo almost 2 years ago. Updated over 1 year ago.

Status:ResolvedStart date:02/05/2018
Priority:NormalDue date:
Assignee:mkittler% Done:

0%

Category:Concrete Bugs
Target version:Done
Difficulty:easy
Duration:

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

History

#1 Updated by mkittler almost 2 years ago

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

#2 Updated by mkittler almost 2 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 almost 2 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 almost 2 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 over 1 year ago

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

#6 Updated by mkittler over 1 year 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 1 year ago

  • Target version changed from Ready to Done

Also available in: Atom PDF