remove any duplicate jobs when locking
This commit is contained in:
@@ -59,9 +59,9 @@ sub jq_queued {
|
|||||||
my $job_type = shift;
|
my $job_type = shift;
|
||||||
|
|
||||||
return schema('netdisco')->resultset('Admin')->search({
|
return schema('netdisco')->resultset('Admin')->search({
|
||||||
device => { '!=' => undef},
|
device => { '!=' => undef},
|
||||||
action => $job_type,
|
action => $job_type,
|
||||||
status => { -like => 'queued%' },
|
status => { -like => 'queued%' },
|
||||||
})->get_column('device')->all;
|
})->get_column('device')->all;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +109,15 @@ sub jq_lock {
|
|||||||
schema('netdisco')->resultset('Admin')
|
schema('netdisco')->resultset('Admin')
|
||||||
->find($job->id, {for => 'update'})
|
->find($job->id, {for => 'update'})
|
||||||
->update({ status => "queued-$fqdn" });
|
->update({ status => "queued-$fqdn" });
|
||||||
|
|
||||||
|
# remove any duplicate jobs, needed because we have race conditions
|
||||||
|
# when queueing jobs of a type for all devices
|
||||||
|
schema('netdisco')->resultset('Admin')->search({
|
||||||
|
device => $job->device,
|
||||||
|
port => $job->port,
|
||||||
|
action => $job->action,
|
||||||
|
subaction => $job->subaction,
|
||||||
|
}, {for => 'update'})->delete();
|
||||||
});
|
});
|
||||||
$happy = true;
|
$happy = true;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user