diff --git a/lib/OpenQA/Shared/Plugin/Gru.pm b/lib/OpenQA/Shared/Plugin/Gru.pm index 2c47963b323..3867603456a 100644 --- a/lib/OpenQA/Shared/Plugin/Gru.pm +++ b/lib/OpenQA/Shared/Plugin/Gru.pm @@ -144,6 +144,7 @@ sub _find_existing_minion_job ($self, $task, $args, $job_ids) { sub _add_jobs_to_gru_task ($self, $gru_id, $job_ids) { my $schema = OpenQA::Schema->singleton; + $schema->svp_begin('try_gru_dependencies'); for my $id (@$job_ids) { # Add job to existing gru task with the same args my $gru_dep = eval { $schema->resultset('GruDependencies')->create({job_id => $id, gru_task_id => $gru_id}); }; @@ -155,9 +156,11 @@ sub _add_jobs_to_gru_task ($self, $gru_id, $job_ids) { # if the GruTask was already deleted meanwhile, we can skip # the rest of the jobs, since the wanted task was done log_debug("GruTask $gru_id already gone, skip assigning jobs (message: $error)"); + $schema->svp_rollback('try_gru_dependencies'); last; } } + $schema->svp_release('try_gru_dependencies'); } sub enqueue ($self, $task, $args = [], $options = {}, $jobs = []) {